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