116 lines
2.8 KiB
JSON
116 lines
2.8 KiB
JSON
{
|
|
"openapi": "3.0.1",
|
|
"info": {
|
|
"title": "Pets API",
|
|
"version": "1.0.0",
|
|
"description": "API for managing pets."
|
|
},
|
|
"servers": [
|
|
{
|
|
"url": "https://api.yourdomain.com"
|
|
}
|
|
],
|
|
"paths": {
|
|
"/pets": {
|
|
"patch": {
|
|
"summary": "Update a pet. Call this with either details for a dog or a cat but not both.",
|
|
"description": "Update a pet. Call this with either details for a dog or a cat but not both.",
|
|
"operationId": "updatePet",
|
|
"requestBody": {
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"oneOf": [
|
|
{ "$ref": "#/components/schemas/Cat" },
|
|
{ "$ref": "#/components/schemas/Dog" }
|
|
],
|
|
"discriminator": {
|
|
"propertyName": "pet_type"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"responses": {
|
|
"200": {
|
|
"description": "Updated"
|
|
}
|
|
}
|
|
},
|
|
"post": {
|
|
"summary": "Create a pet. Call this with either details for a dog or a cat but not both.",
|
|
"description": "Create a pet. Call this with either details for a dog or a cat but not both.",
|
|
"operationId": "createPet",
|
|
"requestBody": {
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"oneOf": [
|
|
{ "$ref": "#/components/schemas/Cat" },
|
|
{ "$ref": "#/components/schemas/Dog" }
|
|
],
|
|
"discriminator": {
|
|
"propertyName": "pet_type"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"responses": {
|
|
"201": {
|
|
"description": "Created"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"components": {
|
|
"schemas": {
|
|
"Pet": {
|
|
"type": "object",
|
|
"required": [ "pet_type" ],
|
|
"properties": {
|
|
"pet_type": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"discriminator": {
|
|
"propertyName": "pet_type"
|
|
}
|
|
},
|
|
"Dog": {
|
|
"allOf": [
|
|
{ "$ref": "#/components/schemas/Pet" },
|
|
{
|
|
"type": "object",
|
|
"properties": {
|
|
"bark": {
|
|
"type": "boolean"
|
|
},
|
|
"breed": {
|
|
"type": "string",
|
|
"enum": [ "Dingo", "Husky", "Retriever", "Shepherd" ]
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"Cat": {
|
|
"allOf": [
|
|
{ "$ref": "#/components/schemas/Pet" },
|
|
{
|
|
"type": "object",
|
|
"properties": {
|
|
"hunts": {
|
|
"type": "boolean"
|
|
},
|
|
"age": {
|
|
"type": "integer"
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
}
|
|
} |