ASP.NET Core 10 OpenApi generates "oneOf" schemas for nullable references for OpenApi 3.1 which is structurely different than what would be idiomatic in OpenAPI 3.0
OpenAPI 3.1
"contact":
{
"oneOf":
[
{
"type": "null"
},
{
"$ref": "#/components/schemas/Person"
}
]
}
When downcasting this to OpenAPI 3.0 we get
"contact":
{
"oneOf":
[
{
"nullable": true
},
{
"$ref": "#/components/schemas/Person"
}
]
}
This is incorrect as { "nullable": true } does not refer to a base schema.
The pattern of "oneOf" with OpenAPI 3.1 should be downcasted to the following:
"contact":
{
"allOf":
{
"$ref": "#/components/schemas/Person"
},
"nullable": true
}
Remarks:
- Probably a pattern of "anyOf" with a
{ "type": "null" } should also be recognized.
- OpenAPI 3.1 "oneOf" with multiple schemas AND a null schema would be required to be downcasted to a "oneOf" without the
{ "type": "null" } and the nullable: true
ASP.NET Core 10 OpenApi generates "oneOf" schemas for nullable references for OpenApi 3.1 which is structurely different than what would be idiomatic in OpenAPI 3.0
OpenAPI 3.1
When downcasting this to OpenAPI 3.0 we get
This is incorrect as
{ "nullable": true }does not refer to a base schema.The pattern of "oneOf" with OpenAPI 3.1 should be downcasted to the following:
Remarks:
{ "type": "null" }should also be recognized.{ "type": "null" }and thenullable: true