[BUG][csharp-netcore] Validate method fails to compile when regex validating a Guid
Created by: flexpaymentsolutions
Description
Since Regex.Match requires a string, the validatable template outputs code that won't compile if the property its checking is a Guid.
It's a minor annoyance but if the api being implement has a lot Guids it can be a pain. See file openapi-generator/modules/openapi-generator/src/main/resources/csharp-netcore/validatable.mustache :78
openapi-generator version
5.4.0
Generation Details
npx @openapitools/openapi-generator-cli generate -i spec.json -g csharp-netcore -o IO.OpenApi.spec --additional-properties=packageName=IO.OpenApi.spec,targetFramework=net5.0
Any library will produce the same result
Steps to reproduce
- Run generator against any spec that contains a call that returns a Guid as a property
Related issues/PRs
None
Suggest a fix
The easiest fix would be to just slap a .ToString() onto the parameter like so: if (false == regex{{{name}}}.Match(this.{{{name}}}.ToString()).Success)
I don't know Mustache well enough to "know what I don't know" so I'm hesitant to create a pull request with the fix. @mandrean @frankyjuang @shibayan @Blackclaws @lucamazzanti