mirror of
https://github.com/ditkrg/rswag.git
synced 2026-01-25 23:32:58 +00:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7ef900ec1d | ||
|
|
c0142093d4 | ||
|
|
1f4ecb3c10 | ||
|
|
aa4e6f2070 | ||
|
|
eadaf34ef6 | ||
|
|
cbaf6cd3e4 | ||
|
|
670c94cc44 | ||
|
|
b86d3063a8 |
14
CHANGELOG.md
14
CHANGELOG.md
@@ -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
|
||||||
|
|||||||
@@ -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|
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
@@ -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
|
||||||
{
|
{
|
||||||
|
|||||||
6
rswag-ui/package-lock.json
generated
6
rswag-ui/package-lock.json
generated
@@ -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=="
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user