mirror of
https://github.com/ditkrg/rswag.git
synced 2026-01-25 07:16:40 +00:00
add support for oneOf anyOf allOf
This commit is contained in:
@@ -49,6 +49,30 @@ RSpec.describe 'Blogs API', type: :request, swagger_doc: 'v1/swagger.json' do
|
||||
end
|
||||
end
|
||||
|
||||
path '/blogs/flexible' do
|
||||
post 'Creates a blog flexible body' do
|
||||
tags 'Blogs'
|
||||
description 'Creates a flexible blog from provided data'
|
||||
operationId 'createFlexibleBlog'
|
||||
consumes 'application/json'
|
||||
produces 'application/json'
|
||||
|
||||
parameter name: :flexible_blog, in: :body, schema: {
|
||||
oneOf: [
|
||||
{ '$ref' => '#/definitions/blog' },
|
||||
{ '$ref' => '#/definitions/flexible_blog' }
|
||||
]
|
||||
}
|
||||
|
||||
let(:flexible_blog) { { blog: { headline: 'my headline', text: 'my text' } } }
|
||||
|
||||
response '201', 'flexible blog created' do
|
||||
schema oneOf: [{ '$ref' => '#/definitions/blog' }, { '$ref' => '#/definitions/flexible_blog' }]
|
||||
run_test!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
path '/blogs/{id}' do
|
||||
parameter name: :id, in: :path, type: :string
|
||||
|
||||
|
||||
@@ -52,9 +52,19 @@ RSpec.configure do |config|
|
||||
id: { type: 'integer' },
|
||||
title: { type: 'string' },
|
||||
content: { type: 'string', 'x-nullable': true },
|
||||
thumbnail: { type: 'string'}
|
||||
thumbnail: { type: 'string', 'x-nullable': true}
|
||||
},
|
||||
required: [ 'id', 'title', 'content', 'thumbnail' ]
|
||||
required: [ 'id', 'title' ]
|
||||
},
|
||||
flexible_blog: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
id: { type: 'integer' },
|
||||
headline: { type: 'string' },
|
||||
text: { type: 'string', nullable: true },
|
||||
thumbnail: { type: 'string', nullable: true }
|
||||
},
|
||||
required: ['id', 'headline']
|
||||
}
|
||||
},
|
||||
securityDefinitions: {
|
||||
|
||||
@@ -155,6 +155,54 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/blogs/flexible": {
|
||||
"post": {
|
||||
"summary": "Creates a blog flexible body",
|
||||
"tags": [
|
||||
"Blogs"
|
||||
],
|
||||
"description": "Creates a flexible blog from provided data",
|
||||
"operationId": "createFlexibleBlog",
|
||||
"parameters": [
|
||||
|
||||
],
|
||||
"responses": {
|
||||
"201": {
|
||||
"description": "flexible blog created",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"oneOf": [
|
||||
{
|
||||
"$ref": "#/components/schemas/blog"
|
||||
},
|
||||
{
|
||||
"$ref": "#/components/schemas/flexible_blog"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"requestBody": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"oneOf": [
|
||||
{
|
||||
"$ref": "#/components/schemas/blog"
|
||||
},
|
||||
{
|
||||
"$ref": "#/components/schemas/flexible_blog"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/blogs/{id}": {
|
||||
"parameters": [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user