Bug Report Checklist
Description
In version 4.0.3, when using an OpenAPI 2.0 input, model properties were generated as nullable. For example, see that the date-time property in the FormatTest class was generated as a DateTime? type in 4.0.3:
https://github.com/OpenAPITools/openapi-generator/blob/v4.0.3/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/FormatTest.cs#L172
But in 4.1.0, the same property is generated as a non-nullable DateTime type:
https://github.com/OpenAPITools/openapi-generator/blob/v4.1.0/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/FormatTest.cs#L172
This is a problem because if a service returns null for these properties in a response, the JSON deserialization fails.
Is there a way to generate nullable properties using an OpenAPI 2.0 input?
openapi-generator version
4.1.0
OpenAPI declaration file content or url
https://github.com/OpenAPITools/openapi-generator/blob/v4.1.0/modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml#L1301
Command line used for generation
See https://github.com/OpenAPITools/openapi-generator/blob/v4.1.0/bin/csharp-petstore-netcore-project.sh#L30
Steps to reproduce
Look at the generated samples in Github for version 4.0.3 and 4.1.0 and compare the types of the properties in the generated models.
Related issues/PRs
I believe this may have been introduced by these pull requests:
#3530
#3537
Suggest a fix
I think the changes made in the above pull requests should only affect OpenAPI 3.0 generation.
Bug Report Checklist
Description
In version 4.0.3, when using an OpenAPI 2.0 input, model properties were generated as nullable. For example, see that the date-time property in the FormatTest class was generated as a DateTime? type in 4.0.3:
https://github.com/OpenAPITools/openapi-generator/blob/v4.0.3/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/FormatTest.cs#L172
But in 4.1.0, the same property is generated as a non-nullable DateTime type:
https://github.com/OpenAPITools/openapi-generator/blob/v4.1.0/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/FormatTest.cs#L172
This is a problem because if a service returns null for these properties in a response, the JSON deserialization fails.
Is there a way to generate nullable properties using an OpenAPI 2.0 input?
openapi-generator version
4.1.0
OpenAPI declaration file content or url
https://github.com/OpenAPITools/openapi-generator/blob/v4.1.0/modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml#L1301
Command line used for generation
See https://github.com/OpenAPITools/openapi-generator/blob/v4.1.0/bin/csharp-petstore-netcore-project.sh#L30
Steps to reproduce
Look at the generated samples in Github for version 4.0.3 and 4.1.0 and compare the types of the properties in the generated models.
Related issues/PRs
I believe this may have been introduced by these pull requests:
#3530
#3537
Suggest a fix
I think the changes made in the above pull requests should only affect OpenAPI 3.0 generation.