8 Commits
jamie ... 2.3.3

Author SHA1 Message Date
Blake Erickson
7ef900ec1d version bump 2021-02-07 07:55:52 -07:00
Blake Erickson
c0142093d4 Update swagger-ui to 3.42.0 2021-02-07 07:47:52 -07:00
Blake Erickson
1f4ecb3c10 update changelog 2021-02-07 06:31:47 -07:00
Blake Erickson
aa4e6f2070 Include example definition in test app
From changes in this commit: eadaf34ef6

we need to include the new output in the test-app swagger.json file
2021-02-06 17:42:23 -07:00
Blake Erickson
eadaf34ef6 Merge pull request #394 from donny741/master
Fix response examples
2021-02-06 07:30:53 -07:00
Donatas Povilaitis
cbaf6cd3e4 Fix response examples 2021-01-29 20:47:46 +02:00
Blake Erickson
670c94cc44 Update version to 2.3.2 in changelog 2021-01-27 14:53:15 -07:00
Blake Erickson
b86d3063a8 Merge pull request #371 from rswag/jamie
PR Grooming
2021-01-27 07:59:59 -07:00
7 changed files with 65 additions and 12 deletions

View File

@@ -4,15 +4,21 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased] ## [Unreleased]
## [2.3.3] - 2021-02-07
### Fixed
- Include response examples [#394](https://github.com/rswag/rswag/pull/394)
### Changed
- Update swagger-ui to 3.42.0
## [2.3.2] - 2021-01-27
### Added ### Added
- RequestBody now supports the `required` flag [#342](https://github.com/rswag/rswag/pull/342) - RequestBody now supports the `required` flag [#342](https://github.com/rswag/rswag/pull/342)
### Changed
### Deprecated
### Removed
### Fixed ### Fixed
- Fix response example rendering [#330](https://github.com/rswag/rswag/pull/330) - Fix response example rendering [#330](https://github.com/rswag/rswag/pull/330)
- Fix empty content block [#347](https://github.com/rswag/rswag/pull/347) - Fix empty content block [#347](https://github.com/rswag/rswag/pull/347)
### Security
## [2.3.1] - 2020-04-08 ## [2.3.1] - 2020-04-08
### Fixed ### Fixed

View File

@@ -18,7 +18,7 @@ Once you have an API that can describe itself in Swagger, you've opened the trea
|Rswag Version|Swagger (OpenAPI) Spec.|swagger-ui| |Rswag Version|Swagger (OpenAPI) Spec.|swagger-ui|
|----------|----------|----------| |----------|----------|----------|
|[master](https://github.com/rswag/rswag/tree/master)|3.0.3|3.28.0| |[master](https://github.com/rswag/rswag/tree/master)|3.0.3|3.42.0|
|[2.3.0](https://github.com/rswag/rswag/tree/2.3.0)|3.0.3|3.23.11| |[2.3.0](https://github.com/rswag/rswag/tree/2.3.0)|3.0.3|3.23.11|
|[2.2.0](https://github.com/rswag/rswag/tree/2.2.0)|2.0|3.18.2| |[2.2.0](https://github.com/rswag/rswag/tree/2.2.0)|2.0|3.18.2|
|[1.6.0](https://github.com/rswag/rswag/tree/1.6.0)|2.0|2.2.5| |[1.6.0](https://github.com/rswag/rswag/tree/1.6.0)|2.0|2.2.5|

View File

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

View File

@@ -28,10 +28,11 @@ module Rswag
{ {
path_item: { template: '/blogs', parameters: [{ type: :string }] }, path_item: { template: '/blogs', parameters: [{ type: :string }] },
operation: { verb: :post, summary: 'Creates a blog', parameters: [{ type: :string }] }, operation: { verb: :post, summary: 'Creates a blog', parameters: [{ type: :string }] },
response: { code: '201', description: 'blog created', headers: { type: :string }, schema: { '$ref' => '#/definitions/blog' } }, response: response_metadata,
document: document document: document
} }
end end
let(:response_metadata) { { code: '201', description: 'blog created', headers: { type: :string }, schema: { '$ref' => '#/definitions/blog' } } }
context 'with the document tag set to false' do context 'with the document tag set to false' do
let(:swagger_doc) { { swagger: '2.0' } } let(:swagger_doc) { { swagger: '2.0' } }
@@ -129,6 +130,47 @@ module Rswag
) )
end end
context 'with response example' do
let(:response_metadata) do
{
code: '201',
description: 'blog created',
headers: { type: :string },
content: { 'application/json' => { example: { foo: :bar } } },
schema: { '$ref' => '#/definitions/blog' }
}
end
it 'adds example to definition' 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' => {
content: {
'application/vnd.my_mime' => {
schema: { '$ref' => '#/definitions/blog' }
},
'application/json' => {
schema: { '$ref' => '#/definitions/blog' },
example: { foo: :bar }
}
},
description: 'blog created',
headers: { schema: { type: :string } }
}
}
}
}
}
)
end
end
context 'with empty content' do context 'with empty content' do
let(:swagger_doc) do let(:swagger_doc) do
{ {

View File

@@ -5,9 +5,9 @@
"requires": true, "requires": true,
"dependencies": { "dependencies": {
"swagger-ui-dist": { "swagger-ui-dist": {
"version": "3.28.0", "version": "3.42.0",
"resolved": "https://registry.npmjs.org/swagger-ui-dist/-/swagger-ui-dist-3.28.0.tgz", "resolved": "https://registry.npmjs.org/swagger-ui-dist/-/swagger-ui-dist-3.42.0.tgz",
"integrity": "sha512-aPkfTzPv9djSiZI1NUkWr5HynCUsH+jaJ0WSx+/t19wq7MMGg9clHm9nGoIpAtqml1G51ofI+I75Ym72pukzFg==" "integrity": "sha512-hTNX6cX7KWtBZgk6ZQSOzsBJhqdCmD5NOIjb6dBPKSnYZidSkIXOcaPMR3+kwxLrj8bDC881bSDlNbLsHikacg=="
} }
} }
} }

View File

@@ -3,6 +3,6 @@
"version": "1.0.0", "version": "1.0.0",
"private": true, "private": true,
"dependencies": { "dependencies": {
"swagger-ui-dist": "3.28.0" "swagger-ui-dist": "3.42.0"
} }
} }

View File

@@ -221,6 +221,12 @@
}, },
"content": { "content": {
"application/json": { "application/json": {
"example": {
"id": 1,
"title": "Hello world!",
"content": "Hello world and hello universe. Thank you all very much!!!",
"thumbnail": "thumbnail.png"
},
"schema": { "schema": {
"$ref": "#/definitions/blog" "$ref": "#/definitions/blog"
} }