Open rauldeheer opened 2 years ago
We found out that setting the required property on the schema will make the generator generate nullability correctly.
{
"openapi": "3.0.1",
"info": {
"title": "OpenAPI definition",
"version": "v0"
},
"servers": [
{
"url": "http://localhost:8080",
"description": "Generated server url"
}
],
"paths": {},
"components": {
"schemas": {
"AccountDto": {
"required": [
"email"
],
"type": "object",
"properties": {
"email": {
"type": "string",
}
}
}
}
}
}
My question now remains; why does the property nullable
do nothing?
Bug Report Checklist
Description
When we generate a client in either Kotlin or Typescript all properties from models become nullable (in Kotlin) or undefined (in Typescript). This means that some models may have nullable/undefined types when they are in fact always defined/not null.
openapi-generator version
CLI version 2.5.2.
OpenAPI declaration file content or url
For the sake of simplicity I've created the following spec file with only one model to be generated:
Generation Details
I use the following CLI command to generate the code (for Kotlin):
With the following config file (for Kotlin):
Steps to reproduce
AccountDto
model.email
.You can see that the class will be generated like this:
Instead of this:
Suggest a fix
Provide a way to make properties not nullable. I've tried to add these properties to the
email
property without success: