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.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
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: falsemeans that the property might not exist in the jsonnullable: falsemeans that the property doesn't accept null as a valueso what to do when the spec document doesn't specify the
defaultkeyword ?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
defaultkeyword whenrequired: falseandnullable: falseignore the provided
required: falseand assume insteadrequired: trueignore the provided
nullable: falseand assumenullable: trueBeta Was this translation helpful? Give feedback.
All reactions