mirror of
https://github.com/ditkrg/rswag.git
synced 2026-01-23 06:16:42 +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|
|
||||
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
|
||||
```
|
||||
|
||||
@ -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
|
||||
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 -%>
|
||||
|
||||
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
|
||||
run_test!
|
||||
end
|
||||
|
||||
@ -129,13 +129,13 @@ module Rswag
|
||||
end
|
||||
|
||||
def upgrade_content!(mime_list, target_node)
|
||||
target_node.merge!(content: {})
|
||||
target_node[:content] ||= {}
|
||||
schema = target_node[:schema]
|
||||
return if mime_list.empty? || schema.nil?
|
||||
|
||||
mime_list.each do |mime_type|
|
||||
# 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
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user