Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #12442
Closed
Open
Issue created May 24, 2022 by Administrator@rootContributor

[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
  1. 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

Assignee
Assign to
Time tracking