[BUG][JAVA] Client generator ignores 'nullable' property
See original GitHub issueDescription
Client generator ignores ‘nullable’ property of the object schema. Instead, javax.annotation.Nullable generation seems to be based on ‘required’ property. This behaviour is incorrect - required fields have to be provided, but not necessarily non-null, i.e { "field" : null }
satisfies the ‘required’.
Nullable is part of OpenAPI 3.0 spec. To make it more robust, x-nullable could be handled, too.
OpenAPI declaration file content or url
"components": {
"schemas": {
"SomeEntity": {
"type": "object",
"properties": {
"name": {
"id": "string",
"nullable": false
}
}
}
}
Related issues/PRs
https://github.com/OpenAPITools/openapi-generator/issues/3264
Issue Analytics
- State:
- Created 4 years ago
- Reactions:8
- Comments:5
Top Results From Across the Web
Openapi generator maven plugin nullable property problem
A property can be mentioned as nullable to pass null value in openApi. OpenApi generator wraps the datatype with JsonNullable as shown below ......
Read more >Changelog - DataStax Java Driver
[improvement] JAVA-852: Ignore peers with null entries during discovery. [bug] JAVA-1005: DowngradingConsistencyRetryPolicy does not work with EACH_QUORUM ...
Read more >Bug descriptions — spotbugs 4.7.3 documentation
Returning a null value in such case is a contract violation and will most likely break client code. NP: Non-null field is not...
Read more >Documentation for the java Generator
This option only works for Java API client, false. gradleProperties, Append additional Gradle properties to the gradle.properties file, null.
Read more >Using Optional and Nullable Properties in API Requests
If a field (whether it is a parameter or a part of a model) is uninitialized, i.e., not specified, then it should be...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The semantics posted by @kkosmrli are what I would expect too. This issue is also impacting us and requires manual post-processing of the generated files. It would be nice to get a fix for this. Thank you!
I also ran into this behaviour today. At the moment it seems the only option is to use
required
to mark fields with@NotNull
. Unfortunately this means that the generated code does not match the specification. According to OAS 3required
just marks a field as mandatory in the object e.g.{"field" : null}
and{"field" : "value"}
is valid and{}
is not.