Reputation: 25153
The documentation says:
Using
default
withrequired
parameters or properties, for example, with path parameters. This does not make sense – if a value is required, the client must always send it, and the default value is never used.
But this is common idiom for databases when column IS NOT NULL
and have DEFAULT
, is not?
Why for OpenAPI this makes no sense?
Upvotes: 3
Views: 5192
Reputation: 97717
Think of function declarations. Consider JavaScript string method indexOf
:
"string".indexOf(searchValue[, fromIndex])
The searchValue
parameter is required and must always be supplied. It does not have a default value - the client must always provide the substring they want to find.
The fromIndex
parameter is optional, and the default value is 0.
Now, if the required parameter searchValue
had a default value, it would mean this parameter is no longer required! It's now optional, as in:
"string".indexOf([searchValue[, fromIndex]])
That's why the defalut
value is an attribute of optional parameters and not required
parameters.
Parameters in OpenAPI follow the same principle. The default
value is for documentation purposes only, to tell the client developers what value the server will use if a client does not supply an optional parameter.
Upvotes: 5