Closed liquorvicar closed 4 years ago
Hmmm, on further inspection it looks like what I'm trying above may not fit the intention for the nullable
key word (even if it does technically adhere to the spec).
There is a proposal to clarify what nullable
means: https://github.com/OAI/OpenAPI-Specification/blob/master/proposals/003_Clarify-Nullable.md
I have found a workaround for now which is to use:
"address": {
"nullable": "true",
"anyof": [
"$ref": "#/components/schemas/Address"
]
},
a reference object can only contain the $ref
key, if it has more than $ref
it is undefined how to resolve the reference. If we want to replace the reference object with the object it points to, and that one defines nullable differently from the local object that would be a conflict and the result is undefined. If you need this, the solution you found is the correct way to do it as far as I see.
As far as I can see, it is valid to set a property
$ref
to be nullable. But I don't think this library handles that.e.g.
I would expect the
address
property to be nullable when this schema is parsed/loaded.