-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- What's the version of OpenAPI Generator used?
- Have you search for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Bounty to sponsor the fix (example)
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
Command line used for generation
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.