mirror of
https://github.com/ditkrg/rswag.git
synced 2026-01-24 23:06:41 +00:00
keep examples content
This commit is contained in:
parent
7ceedab4cb
commit
9c297317b2
@ -597,7 +597,11 @@ To enable examples generation from responses add callback above run_test! like:
|
|||||||
|
|
||||||
```
|
```
|
||||||
after do |example|
|
after do |example|
|
||||||
example.metadata[:response][:examples] = { 'application/json' => JSON.parse(response.body, symbolize_names: true) }
|
example.metadata[:response][:content] = {
|
||||||
|
'application/json' => {
|
||||||
|
example: JSON.parse(response.body, symbolize_names: true)
|
||||||
|
}
|
||||||
|
}
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -900,4 +904,3 @@ docker run -d -p 80:8080 swaggerapi/swagger-editor
|
|||||||
```
|
```
|
||||||
This will run the swagger editor in the docker daemon and can be accessed
|
This will run the swagger editor in the docker daemon and can be accessed
|
||||||
at ```http://localhost```. From here, you can use the UI to load the generated swagger.json to validate the output.
|
at ```http://localhost```. From here, you can use the UI to load the generated swagger.json to validate the output.
|
||||||
|
|
||||||
|
|||||||
@ -19,7 +19,11 @@ RSpec.describe '<%= controller_path %>', type: :request do
|
|||||||
<% end -%>
|
<% end -%>
|
||||||
|
|
||||||
after do |example|
|
after do |example|
|
||||||
example.metadata[:response][:examples] = { 'application/json' => JSON.parse(response.body, symbolize_names: true) }
|
example.metadata[:response][:content] = {
|
||||||
|
'application/json' => {
|
||||||
|
example: JSON.parse(response.body, symbolize_names: true)
|
||||||
|
}
|
||||||
|
}
|
||||||
end
|
end
|
||||||
run_test!
|
run_test!
|
||||||
end
|
end
|
||||||
|
|||||||
@ -129,13 +129,13 @@ module Rswag
|
|||||||
end
|
end
|
||||||
|
|
||||||
def upgrade_content!(mime_list, target_node)
|
def upgrade_content!(mime_list, target_node)
|
||||||
target_node.merge!(content: {})
|
target_node[:content] ||= {}
|
||||||
schema = target_node[:schema]
|
schema = target_node[:schema]
|
||||||
return if mime_list.empty? || schema.nil?
|
return if mime_list.empty? || schema.nil?
|
||||||
|
|
||||||
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] = { schema: schema }
|
(target_node[:content][mime_type] ||= {}).merge!(schema: schema)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user