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
  • #13240
Closed
Open
Issue created Aug 21, 2022 by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items

[BUG][csharp-netcore] fail to resolve references to enum types with camlCase names

Created by: fujieda

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

Foo class generated from the following declaration has a comparison between null and the property 'Bar' of which type is EnumA.

openapi: 3.0.0
info:
  title: enum ref test
  version: 1.0.0
paths: {}
components:
  schemas:
    foo:
      type: object
      properties:
        bar:
          $ref: '#/components/schemas/enumA'
    enumA:
      type: string
      enum:
        - "a"
        - "b"
public bool Equals(Foo input)
{
    if (input == null)
    {
        return false;
    }
    return 
        (
            this.Bar == input.Bar ||
            (this.Bar != null &&
            this.Bar.Equals(input.Bar))
        );
}

The code generator must omit the comparison because EnumA is a value type. The generator seems to fail to resolve the ref #/components/schemas/enumA.

If I change the key of the enum declarlation to EnumA as follows, the result doesn't have the comparison.

openapi: 3.0.0
info:
  title: enum ref test
  version: 1.0.0
paths: {}
components:
  schemas:
    foo:
      type: object
      properties:
        bar:
          $ref: '#/components/schemas/EnumA'
    EnumA:
      type: string
      enum:
        - "a"
        - "b"
public bool Equals(Foo input)
{
    if (input == null)
    {
        return false;
    }
    return 
        (
            this.Bar == input.Bar ||
            this.Bar.Equals(input.Bar)
        );
}
openapi-generator version

openapi-generator-cli-6.1.0-20220820.044513-79.jar

Steps to reproduce

Just run the following command. `simple.yml' contains the above declarations.

java -jar openapi-generator-cli-6.1.0-20220820.044513-79.jar generate -g csharp-netcore -i simple.yml
Suggest a fix

I will submit a PR to fix this.

Assignee
Assign to
Time tracking