OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
Is your feature request related to a problem? Please describe.
When using the 'csharp-netcore' generator even with nullableReferenceTypes set to true and targetting only net6.0 / net7.0 nullable reference/value types in generated models do not use nullable annotations.
This leads projects referencing generated models and assigning null values to nullable elements generating warnings.
I don't know if I'm doing something wrong or if this is not currently supported by the generator.
Describe the solution you'd like
When nullableReferenceTypes is set to true the reference types set to nullable or not required should have nullable annotations.
A new config option nullableValueTypes could also be added to add a nullable annotation to value types in models differently from reference types.
Describe alternatives you've considered
Disable nullable context warnings in projects referencing generated models assigning null values.
Currently working on custom overriding model templates as it seems from what I saw the generator just does not support this currently.
Additional context
If I didn't miss something and this is something currently not supported by the generator I can work on a new pull request supporting it.
Is your feature request related to a problem? Please describe.
When using the 'csharp-netcore' generator even with
nullableReferenceTypes
set to true and targetting only net6.0 / net7.0 nullable reference/value types in generated models do not use nullable annotations. This leads projects referencing generated models and assigning null values to nullable elements generating warnings. I don't know if I'm doing something wrong or if this is not currently supported by the generator.Describe the solution you'd like
When
nullableReferenceTypes
is set to true the reference types set to nullable or not required should have nullable annotations. A new config optionnullableValueTypes
could also be added to add a nullable annotation to value types in models differently from reference types.Describe alternatives you've considered
Disable nullable context warnings in projects referencing generated models assigning null values. Currently working on custom overriding model templates as it seems from what I saw the generator just does not support this currently.
Additional context
If I didn't miss something and this is something currently not supported by the generator I can work on a new pull request supporting it.
Reproducible example
OpenApi definition (openapi.yaml):
Generated BearerToken class
What I expected (truncated to show only changed elements):
Command used:
openapi-generator-cli generate -i ./openapi.yaml -g csharp-netcore -o ./Autogenerated -c ./openapi-generator-config.json
Config files:
openapitools.json
openapi-generator-config.json