mirror of
https://github.com/ditkrg/rswag.git
synced 2026-01-25 07:16:40 +00:00
Merge pull request #4 from jdanielian/response-example
Only automatically save examples if examples are not given explicitly…
This commit is contained in:
commit
6467ce6543
12
.travis.yml
12
.travis.yml
@ -5,17 +5,25 @@ rvm:
|
|||||||
|
|
||||||
env:
|
env:
|
||||||
- RAILS_VERSION=5.2.0
|
- RAILS_VERSION=5.2.0
|
||||||
- RAILS_VERSION=4.2.8
|
# - RAILS_VERSION=4.2.8
|
||||||
|
|
||||||
cache:
|
cache:
|
||||||
directories:
|
directories:
|
||||||
- /home/travis/.rvm/gems/ruby-2.5.1
|
- /home/travis/.rvm/gems/ruby-2.5.1
|
||||||
|
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
packages:
|
||||||
|
- libqtwebkit-dev
|
||||||
|
- libqtwebkit4
|
||||||
|
|
||||||
install: ./ci/build.sh
|
install: ./ci/build.sh
|
||||||
|
|
||||||
|
services:
|
||||||
|
- xvfb
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- export DISPLAY=:99.0
|
- export DISPLAY=:99.0
|
||||||
- sh -e /etc/init.d/xvfb start
|
|
||||||
- sleep 3
|
- sleep 3
|
||||||
|
|
||||||
script: ./ci/test.sh
|
script: ./ci/test.sh
|
||||||
|
|||||||
@ -238,7 +238,9 @@ module OpenApi
|
|||||||
|
|
||||||
if body_parameter && respond_to?(body_parameter[:name]) && example.metadata[:operation][:requestBody][:content]['application/json']
|
if body_parameter && respond_to?(body_parameter[:name]) && example.metadata[:operation][:requestBody][:content]['application/json']
|
||||||
# save response examples by default
|
# save response examples by default
|
||||||
|
if example.metadata[:response][:examples].nil? || example.metadata[:response][:examples].empty?
|
||||||
example.metadata[:response][:examples] = { 'application/json' => JSON.parse(response.body, symbolize_names: true) } unless response.body.to_s.empty?
|
example.metadata[:response][:examples] = { 'application/json' => JSON.parse(response.body, symbolize_names: true) } unless response.body.to_s.empty?
|
||||||
|
end
|
||||||
|
|
||||||
# save request examples using the let(:param_name) { REQUEST_BODY_HASH } syntax in the test
|
# save request examples using the let(:param_name) { REQUEST_BODY_HASH } syntax in the test
|
||||||
if response.code.to_s =~ /^2\d{2}$/
|
if response.code.to_s =~ /^2\d{2}$/
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user