Adds anyOf support to requestBody

This commit is contained in:
Jay Danielian
2019-07-20 13:50:38 -04:00
parent eb4e6045c5
commit cd348b53f8
6 changed files with 145 additions and 0 deletions

View File

@@ -105,6 +105,16 @@
"schema": {
"$ref": "#/components/schemas/blog"
}
},
"test/plain": {
"schema": {
"type": "string"
}
},
"application/xml": {
"schema": {
"$ref": "#/components/schemas/blog"
}
}
}
},
@@ -183,6 +193,64 @@
}
}
},
"/blogs/flexible": {
"post": {
"summary": "Creates a blog flexible body",
"tags": [
"Blogs"
],
"description": "Creates a flexible blog from provided data",
"operationId": "createFlexibleBlog",
"requestBody": {
"required": true,
"content": {
"application/json": {
"examples": {
"flexible_blog": {
"value": {
"blog": {
"headline": "my headline",
"text": "my text"
}
}
}
},
"schema": {
"oneOf": [
{
"$ref": "#/components/schemas/blog"
},
{
"$ref": "#/components/schemas/flexible_blog"
}
]
}
}
}
},
"parameters": [
],
"responses": {
"201": {
"description": "flexible blog created",
"content": {
"application/json": {
"example": {
"id": 1,
"title": "my headline",
"content": "my text",
"thumbnail": null
},
"schema": {
"$ref": "#/components/schemas/blog"
}
}
}
}
}
}
},
"/blogs/{id}": {
"get": {
"summary": "Retrieves a blog",
@@ -336,6 +404,29 @@
"content",
"thumbnail"
]
},
"flexible_blog": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"headline": {
"type": "string"
},
"text": {
"type": "string",
"nullable": true
},
"thumbnail": {
"type": "string"
}
},
"required": [
"id",
"headline",
"thumbnail"
]
}
},
"securitySchemes": {