mirror of
https://github.com/ditkrg/rswag.git
synced 2026-01-25 23:32:58 +00:00
Compare commits
16 Commits
2.3.3
...
revert-300
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
989aab656f | ||
|
|
f7036b7e5a | ||
|
|
84ab7a9e4c | ||
|
|
0169fbab66 | ||
|
|
4c42ad5f97 | ||
|
|
b91b6e5f1e | ||
|
|
a34c931bb6 | ||
|
|
4b7ab9d381 | ||
|
|
3d3d93f3ab | ||
|
|
0aca50c66c | ||
|
|
9644a16bce | ||
|
|
52939874d6 | ||
|
|
f8dbd98bbc | ||
|
|
9916d3f0b0 | ||
|
|
56eec5948e | ||
|
|
7b01ae1aa1 |
2
.github/workflows/ruby.yml
vendored
2
.github/workflows/ruby.yml
vendored
@@ -11,7 +11,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
ruby: [2.6, 2.7]
|
||||
ruby: [2.6, 2.7, truffleruby-head]
|
||||
rails: [5.2.4.4, 6.0.3.4]
|
||||
env:
|
||||
RAILS_VERSION: ${{ matrix.rails }}
|
||||
|
||||
@@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [2.4.0] - 2021-02-09
|
||||
### Added
|
||||
- Added `SWAGGER_DRY_RUN` env variable [#274](https://github.com/rswag/rswag/pull/274)
|
||||
|
||||
## [2.3.3] - 2021-02-07
|
||||
|
||||
### Fixed
|
||||
|
||||
6
Gemfile
6
Gemfile
@@ -25,18 +25,20 @@ end
|
||||
gem 'rswag-api', path: './rswag-api'
|
||||
gem 'rswag-ui', path: './rswag-ui'
|
||||
|
||||
group :development, :test do
|
||||
gem 'rswag-specs', path: './rswag-specs'
|
||||
end
|
||||
|
||||
group :test do
|
||||
gem 'capybara'
|
||||
gem 'geckodriver-helper'
|
||||
gem 'generator_spec'
|
||||
gem 'rspec-rails'
|
||||
gem 'selenium-webdriver'
|
||||
gem 'rswag-specs', path: './rswag-specs'
|
||||
gem 'test-unit'
|
||||
end
|
||||
|
||||
group :development do
|
||||
gem 'rswag-specs', path: './rswag-specs'
|
||||
gem 'rubocop'
|
||||
end
|
||||
|
||||
|
||||
11
README.md
11
README.md
@@ -616,15 +616,12 @@ after do |example|
|
||||
end
|
||||
```
|
||||
|
||||
You need to disable --dry-run option for Rspec > 3
|
||||
#### Dry Run Option ####
|
||||
|
||||
<!-- This is now enabled by default in rswag.
|
||||
You need to set the ``` config.swagger_dry_run = false``` value in the spec/spec_helper.rb file.
|
||||
This is one of the more powerful features of rswag. When rswag runs your integration test suite via ```bundle exec rspec```, it will capture the request and response bodies and output those values in the examples section.
|
||||
These integration tests are usually written with ```let``` variables for post body parameters, and since its an integration test the service is returning actual values.
|
||||
We might as well re-use these values and embed them into the generated swagger to provide a more real world example for request/response examples. -->
|
||||
The `--dry-run` option is enabled by default for Rspec 3, but if you need to
|
||||
disable it you can use the environment varible `SWAGGER_DRY_RUN=0` during the
|
||||
generation command or add the following to your `config/environments/test.rb`:
|
||||
|
||||
Add to config/environments/test.rb:
|
||||
```ruby
|
||||
RSpec.configure do |config|
|
||||
config.swagger_dry_run = false
|
||||
|
||||
@@ -28,9 +28,11 @@ module Rswag
|
||||
end
|
||||
|
||||
def swagger_dry_run
|
||||
@swagger_dry_run ||= begin
|
||||
@rspec_config.swagger_dry_run.nil? || @rspec_config.swagger_dry_run
|
||||
return @swagger_dry_run if defined? @swagger_dry_run
|
||||
if ENV.key?('SWAGGER_DRY_RUN')
|
||||
@rspec_config.swagger_dry_run = ENV['SWAGGER_DRY_RUN'] == '1'
|
||||
end
|
||||
@swagger_dry_run = @rspec_config.swagger_dry_run.nil? || @rspec_config.swagger_dry_run
|
||||
end
|
||||
|
||||
def swagger_format
|
||||
|
||||
@@ -50,7 +50,11 @@ module Rswag
|
||||
.merge(schemas)
|
||||
|
||||
errors = JSON::Validator.fully_validate(validation_schema, body)
|
||||
raise UnexpectedResponse, "Expected response body to match schema: #{errors[0]}" if errors.any?
|
||||
return unless errors.any?
|
||||
|
||||
raise UnexpectedResponse,
|
||||
"Expected response body to match schema: #{errors[0]}\n" \
|
||||
"Response body: #{JSON.pretty_generate(JSON.parse(body))}"
|
||||
end
|
||||
|
||||
def definitions_or_component_schemas(swagger_doc, version)
|
||||
@@ -62,7 +66,7 @@ module Rswag
|
||||
swagger_doc.slice(:definitions)
|
||||
else
|
||||
components = swagger_doc[:components] || {}
|
||||
{ components: { schemas: components[:schemas] } }
|
||||
{ components: components }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user