[BUG][crystal][client] Optional properties should have nillable types in models
Created by: cyangle
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
Crystal lang supports nillable data types. When value nil or missing value is allowed for a variable, the data type for it should be nillable.
A variable or property is nillable in below scenarios:
- It's NOT REQUIRED, in other words, it's OPTIONAL
-
It's both REQUIRED and NULLABLEnullable has been removed from OAS 3.1
When the above two types of nillable variables with nil values are serialized into json/xml, they should be handled differently:
- The OPTIONAL variables should be omitted from the json string
The NULLABLE REQUIRED variables MUST be included in the json string with null values- REQUIRED variables CAN NOT have nil/null values, thus will never emit null values
openapi-generator version
All versions supporting crystal client generator, I'm using master branch version.
OpenAPI declaration file content or url
pet store api spec
Generation Details
Issue exists in the pet store sample code
Steps to reproduce
Related issues/PRs
Suggest a fix
Mark model properties as nillable when applicable