Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
5 of 6 tasks
fujieda opened this issue Aug 21, 2022 · 0 comments · Fixed by #13242
Closed
5 of 6 tasks

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

fujieda opened this issue Aug 21, 2022 · 0 comments · Fixed by #13242

Comments

@fujieda
Copy link
Contributor

fujieda commented Aug 21, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant