-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Open
Labels
Description
Describe the bug
If a discriminated schema shares a common ancestor (schema) with another discriminated schema, extra schemas are shown in the UI (namely the two discriminated schemas).
Expected behavior
I would expect only the types listed in the mapping section to be shown.
Minimal reproducible OpenAPI snippet(if possible)
{
"openapi": "3.0.1",
"info": {
"title": "My API",
"version": "v1"
},
"paths": {
"/animals": {
"post": {
"summary": "Create an animal",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreateAnimalReqDto"
}
}
}
}
}
}
},
"components": {
"schemas": {
"CreateAnimalReqDto": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"mammal": {
"$ref": "#/components/schemas/MammalDto"
},
"reptile": {
"$ref": "#/components/schemas/ReptileDto"
}
}
},
"AnimalDto": {
"type": "object"
},
"MammalDto": {
"allOf": [
{
"$ref": "#/components/schemas/AnimalDto"
},
{
"type": "object",
"properties": {
"type": {
"type": "string"
}
},
"discriminator": {
"propertyName": "type",
"mapping": {
"cat": "#/components/schemas/CatDto",
"dog": "#/components/schemas/DogDto"
}
}
}
]
},
"ReptileDto": {
"allOf": [
{
"$ref": "#/components/schemas/AnimalDto"
},
{
"type": "object",
"properties": {
"type": {
"type": "string"
}
},
"discriminator": {
"propertyName": "type",
"mapping": {
"lizard": "#/components/schemas/LizardDto"
}
}
}
]
},
"CatDto": {
"allOf": [
{
"$ref": "#/components/schemas/MammalDto"
},
{
"type": "object"
}
]
},
"DogDto": {
"allOf": [
{
"$ref": "#/components/schemas/MammalDto"
},
{
"type": "object"
}
]
},
"LizardDto": {
"allOf": [
{
"$ref": "#/components/schemas/ReptileDto"
},
{
"type": "object"
}
]
}
}
}
}
Screenshots
(highlighted discriminator values are invalid)
Additional context
N/A