Bug Report Checklist
Description
The csharp-netcore generator generates invalid C# if an enum is set as required in a definition. With the enum property name present in the "required" object inside the definition of ObjectCreateArgs, the C# below is generated as a constructor for ObjectCreateArgs:
public ObjectCreateArgs(ObjectType objectType = default(ObjectType))
{
// to ensure "objectType" is required (not null)
this.ObjectType = objectType ?? throw new ArgumentNullException("snip");;
}
This is invalid C# because objectType is not nullable, therefore the null coalescing operator can't be used with it.
openapi-generator version
4.2.3
OpenAPI declaration file content or url
Click here (rename extension to .json)
Command line used for generation
java -jar openapi-generator-cli.jar generate -i swagger.json -g csharp-netcore -o test-csharp
Steps to reproduce
Run the above command.
Suggest a fix
Enums are not nullable unless declared with ? like other types, so they should be treated as such.
Bug Report Checklist
Description
The csharp-netcore generator generates invalid C# if an enum is set as required in a definition. With the enum property name present in the "required" object inside the definition of
ObjectCreateArgs, the C# below is generated as a constructor forObjectCreateArgs:This is invalid C# because
objectTypeis not nullable, therefore the null coalescing operator can't be used with it.openapi-generator version
4.2.3
OpenAPI declaration file content or url
Click here (rename extension to .json)
Command line used for generation
Steps to reproduce
Run the above command.
Suggest a fix
Enums are not nullable unless declared with
?like other types, so they should be treated as such.