Open
Description
Hi,
In OpenAPI 3.0 it's a common pattern to represent a reference that can be null as an allOf
with nullable: true
.
However, if you set the default
to null
, openapi-spec-validator
attempts to validate null
against the referenced schema, and returns an error. The default should take into account the nullability of the schema that it's part of, not just the referenced allOf
.
{
"info": {
"title": "Example",
"version": "v1",
},
"openapi": "3.0.2",
"components": {
"schemas": {
"FooSchema": {
"title": "FooSchema",
"type": "object"
},
"BarSchema": {
"allOf": [
{
"$ref": "#/components/schemas/FooSchema"
}
],
"nullable": true,
"default": null
}
}
},
"paths": {}
}
Failed validating 'type' in schema['allOf'][0]:
{'title': 'FooSchema', 'type': 'object'}
On instance:
None
Metadata
Metadata
Assignees
Labels
No labels