6 Commits
2.3.3 ... 2.4.0

Author SHA1 Message Date
Blake Erickson
0aca50c66c Update changelog with 2.4.0 info 2021-02-09 11:51:34 -07:00
Blake Erickson
9644a16bce Merge branch 'splitpayments-dry-run-env' 2021-02-09 08:07:35 -07:00
Blake Erickson
52939874d6 Clean up README merge conflict 2021-02-09 08:05:58 -07:00
Igor Kapkov
9916d3f0b0 Merge branch 'master' into dry-run-env 2020-03-25 16:59:30 +11:00
Igor Kapkov
56eec5948e Update readme 2020-03-25 16:57:58 +11:00
Igor Kapkov
7b01ae1aa1 Add ENV var to configure --dry-run 2020-01-22 15:54:24 +11:00
3 changed files with 12 additions and 9 deletions

View File

@@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
## [Unreleased] ## [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 ## [2.3.3] - 2021-02-07
### Fixed ### Fixed

View File

@@ -616,15 +616,12 @@ after do |example|
end end
``` ```
You need to disable --dry-run option for Rspec > 3 #### Dry Run Option ####
<!-- This is now enabled by default in rswag. The `--dry-run` option is enabled by default for Rspec 3, but if you need to
You need to set the ``` config.swagger_dry_run = false``` value in the spec/spec_helper.rb file. disable it you can use the environment varible `SWAGGER_DRY_RUN=0` during the
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. generation command or add the following to your `config/environments/test.rb`:
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. -->
Add to config/environments/test.rb:
```ruby ```ruby
RSpec.configure do |config| RSpec.configure do |config|
config.swagger_dry_run = false config.swagger_dry_run = false

View File

@@ -28,9 +28,11 @@ module Rswag
end end
def swagger_dry_run def swagger_dry_run
@swagger_dry_run ||= begin return @swagger_dry_run if defined? @swagger_dry_run
@rspec_config.swagger_dry_run.nil? || @rspec_config.swagger_dry_run if ENV.key?('SWAGGER_DRY_RUN')
@rspec_config.swagger_dry_run = ENV['SWAGGER_DRY_RUN'] == '1'
end end
@swagger_dry_run = @rspec_config.swagger_dry_run.nil? || @rspec_config.swagger_dry_run
end end
def swagger_format def swagger_format