Open
Description
Using Swagger UI v2.2.3
Swagger file:
{
"swagger": "2.0",
"info": {
"title": "Animals yo!",
"description": "An API for animals",
"version": "1.0.0"
},
"produces": [
"application/json"
],
"paths": {
"/animal": {
"get": {
"summary": "Retrieves an animal",
"responses": {
"200": {
"description": "Animal",
"schema": {
"$ref": "#/definitions/Animal"
}
}
}
},
"post": {
"summary": "Animal",
"parameters": [
{
"in": "body",
"name": "animal",
"required": true,
"schema": {
"$ref": "#/definitions/Animal"
}
}
],
"responses": {
"200": {
"description": "Animal",
"schema": {
"$ref": "#/definitions/Animal"
}
}
}
}
}
},
"definitions": {
"Animal": {
"additionalProperties": true,
"discriminator": "animalType",
"required": [
"name",
"animalType"
],
"properties": {
"name": {
"type": "string"
},
"animalType": {
"type": "string",
"enum": [
"Cat",
"Dog"
]
}
}
},
"Cat": {
"allOf": [
{
"$ref": "#/definitions/Animal"
}
],
"required": [
"huntingSkill"
],
"properties": {
"huntingSkill": {
"type": "string",
"description": "Skill of hunting",
"default": "lazy",
"enum": [
"lazy",
"clueless",
"adventurous",
"aggressive"
]
}
}
},
"Dog": {
"allOf": [
{
"$ref": "#/definitions/Animal"
}
],
"required": [
"packSize"
],
"properties": {
"packSize": {
"type": "integer",
"format": "int32",
"description": "Size of the pack",
"default": 0,
"minimum": 0
}
}
}
}
}
What I expect to see:
Under GET /animals
some indication that a Dog
or Cat
may actually be returned with corresponding huntingSkill
or packSize
parameters.
Under POST /animals
parameters section a text box corresponding to huntingSkill
when animalType
dropdown is set to Cat
, and a packSize
text box when animalType
is set to Dog
What I actually see:
Basic Animal
represented for both GET
and POST
.
If I change the schema $ref
in GET
or POST
to one of the options then the model will show all fields for an Animal
plus the specific type of animal. However the animalType
parameter can still be changed to the other type.