Merge remote-tracking branch 'psmandzich/master' into jamie

This commit is contained in:
Jamie Macey 2020-10-17 13:21:28 -07:00
commit b3fa5ba54e
3 changed files with 62 additions and 37 deletions

View File

@ -129,9 +129,10 @@ module Rswag
end
def upgrade_content!(mime_list, target_node)
target_node[:content] ||= {}
schema = target_node[:schema]
return if mime_list.empty? || schema.nil?
target_node[:content] ||= {}
target_node.merge!(content: {})
mime_list.each do |mime_type|
# TODO upgrade to have content-type specific schema

View File

@ -127,6 +127,56 @@ module Rswag
)
end
context 'with empty content' do
let(:swagger_doc) do
{
openapi: '3.0.1',
basePath: '/foo',
schemes: ['http', 'https'],
host: 'api.example.com',
components: {
securitySchemes: {
myClientCredentials: {
type: :oauth2,
flow: :application,
token_url: :somewhere
},
myAuthorizationCode: {
type: :oauth2,
flow: :accessCode,
token_url: :somewhere
},
myImplicit: {
type: :oauth2,
flow: :implicit,
token_url: :somewhere
}
}
}
}
end
it 'converts query and path params, type: to schema: { type: }' do
expect(swagger_doc.slice(:paths)).to match(
paths: {
'/blogs' => {
parameters: [{ schema: { type: :string } }],
post: {
parameters: [{ schema: { type: :string } }],
summary: 'Creates a blog',
responses: {
'201' => {
description: 'blog created',
headers: { schema: { type: :string } }
}
}
}
}
}
)
end
end
it 'converts basePath, schemas and host to urls' do
expect(swagger_doc.slice(:servers)).to match(
servers: {

View File

@ -21,14 +21,10 @@
],
"responses": {
"204": {
"description": "Valid credentials",
"content": {
}
"description": "Valid credentials"
},
"401": {
"description": "Invalid credentials",
"content": {
}
"description": "Invalid credentials"
}
}
}
@ -49,14 +45,10 @@
],
"responses": {
"204": {
"description": "Valid credentials",
"content": {
}
"description": "Valid credentials"
},
"401": {
"description": "Invalid credentials",
"content": {
}
"description": "Invalid credentials"
}
}
}
@ -80,14 +72,10 @@
],
"responses": {
"204": {
"description": "Valid credentials",
"content": {
}
"description": "Valid credentials"
},
"401": {
"description": "Invalid credentials",
"content": {
}
"description": "Invalid credentials"
}
}
}
@ -105,9 +93,7 @@
],
"responses": {
"201": {
"description": "blog created",
"content": {
}
"description": "blog created"
},
"422": {
"description": "invalid request",
@ -148,9 +134,7 @@
],
"responses": {
"406": {
"description": "unsupported accept header",
"content": {
}
"description": "unsupported accept header"
}
}
}
@ -237,12 +221,6 @@
},
"content": {
"application/json": {
"example": {
"id": 1,
"title": "Hello world!",
"content": "Hello world and hello universe. Thank you all very much!!!",
"thumbnail": "thumbnail.png"
},
"schema": {
"$ref": "#/definitions/blog"
}
@ -250,9 +228,7 @@
}
},
"404": {
"description": "blog not found",
"content": {
}
"description": "blog not found"
}
}
}
@ -280,9 +256,7 @@
],
"responses": {
"200": {
"description": "blog updated",
"content": {
}
"description": "blog updated"
}
},
"requestBody": {