I attempted to introduce nullable properties in an API which has been designed using openapi 3 specifications. The idea is to always return the properties to the client, whether their values are null or not.
YAML file (I tried first without default, with same results):
property:
type: integer
nullable: true
default: null
Generated Java code:
@JsonProperty("property")
private JsonNullable<Integer> property = JsonNullable.undefined();
Response from API:
"property": {
"present": true
}
So the result is always "present: true" whether or not the property is null or not. Without nullability it works out just fine, except for the null values being removed from the response which is undesireable.
Any ideas?
P.S. The property isn't actually named as "property"
Edit: configuration:
<generateAliasAsModel>true</generateAliasAsModel>
<inputSpec>./api/interface1.yaml</inputSpec>
<generatorName>spring</generatorName>
<enablePostProcessFile>true</enablePostProcessFile>
<configOptions>
<sourceFolder>src/main/java</sourceFolder>
<library>spring-boot</library>
<java8>true</java8>
<interfaceOnly>true</interfaceOnly>
<useOptional>true</useOptional>
</configOptions>