Open alexpyc opened 6 months ago
Same problem here
what does it mean if value not present it it is a non-nullable field?
IMHO the current behavior to add null values for nullable non required fields is wrong
This also happens with query params with dart-dio generator and json-serializable. This is my schema
{
"schema": {
"type": "array",
"items": {
"type": "object",
"required": [
"messageId",
"sender",
"message"
],
"properties": {
"message": {
"type": "string"
},
"messageId": {
"type": "integer",
"format": "int64"
},
"sender": {
"type": "string",
"enum": [
"User",
"Assistant",
"System",
"Function"
]
}
}
}
}
}
When doing
await client.getDefaultApi().getMessages(chatId: 2, limit: 10, beforeMessageId: 0)
I expect something like
GET /chats/messages?chat_id=2&before_message_id=0&limit=10
but instead the generated request is:
GET /chats/messages?chat_id=2&before_message_id=0&after_message_id&limit=10
Bug Report Checklist
Description
Dart generator always insert null for non-required non-nullable field if a value is not provided. However, it seems not the specified behaviour.
openapi-generator version
7.5.0
OpenAPI declaration file content or url
Generation Details
java -jar openapi-generator-cli.jar generate -i {input filename} -g dart -o {output directory name}
Steps to reproduce
Generate output with the above code snippet
Related issues/PRs
https://github.com/OpenAPITools/openapi-generator/pull/12569/commits/8002e558858e252d78248bd9db51a24498780360
Suggest a fix
This PR comment should point out the issue. Non-required, non-nullable field should not by default assign a null value which should be contradictory to how JSON schema treats non-required field.