Clarify how to handle default value on non-nullable optional properties when "default" keyword is not specified #2807
Replies: 2 comments 4 replies
-
Not sure I follow the issue here (and I tried checking the linked issue as well). Why is the |
Beta Was this translation helpful? Give feedback.
-
@ahmednfwela if there's no default there's no default. In some languages that makes sense, as the field can be completely omitted, or set to some sort of |
Beta Was this translation helpful? Give feedback.
-
Related OpenAPITools/openapi-generator#10972
Spec version: 3.0.3
the spec doesn't indicate how to handle model properties in the following case:
required: false
means that the property might not exist in the jsonnullable: false
means that the property doesn't accept null as a valueso what to do when the spec document doesn't specify the
default
keyword ?assume default is null (works only for properties where
nullable: true
, otherwise it will break the spec)assume default to be of same type as type, so for non-nullable types that would be
"boolean" => false
"object" => { }
"array" => [ ]
"number"/"integer" => 0
"string" => ""
make it required to specify the
default
keyword whenrequired: false
andnullable: false
ignore the provided
required: false
and assume insteadrequired: true
ignore the provided
nullable: false
and assumenullable: true
Beta Was this translation helpful? Give feedback.
All reactions