Rswag: Using rspec "Rswag::Specs::SwaggerFormatter" disables test run

Created on 12 Mar 2019  Â·  5Comments  Â·  Source: rswag/rswag

Observed

Running the following command will generate the OpenAPI v2.0 documents, but won't run the tests.
Note: without --dry-run, so running tests is expected.

bundle exec rspec spec/integration/ --format Rswag::Specs::SwaggerFormatter 

Expected

I expect that the tests would be evaluated, as they would with bundle exec rspec spec/integration/, and additionally the OpenAPI document get's saved.

Environment

  • ruby 2.6.1p33
  • rails (5.2.2)
  • rspec-core (3.8.0)
  • rspec-rails (3.8.2)
  • rswag (2.0.5)
# spec/swagger_helper.rb
RSpec.configure do |config|
–
  config.swagger_dry_run = false
…
end

Most helpful comment

Running be rspec spec/integration/ --format documentation --format Rswag::Specs::SwaggerFormatter will run the tests, and additionally generate the swagger doc.

it seems the --dry-run option is not necessary, as the specs wont run nonetheless.

All 5 comments

Running be rspec spec/integration/ --format documentation --format Rswag::Specs::SwaggerFormatter will run the tests, and additionally generate the swagger doc.

it seems the --dry-run option is not necessary, as the specs wont run nonetheless.

@salzig That helped me out a ton. I was trying to use the after hook described in the docs to create examples automatically and couldn't figure out why it wasn't working.

Running be rspec spec/integration/ --format documentation --format Rswag::Specs::SwaggerFormatter will run the tests, and additionally generate the swagger doc.

I had a similar but slightly different issue but this solution helped me.

We had a spec that was failing, and SwaggerFormatter ignored/swallowed the errors, but still caused rspec to return a failure status code (1) when running it from a shell script. Using another formatter alongside SwaggerFormatter should be the recommended setup (if not already)

rspec spec/integration/ --format documentation --format Rswag::Specs::SwaggerFormatter works!
Where is this feature documented? I only see the https://github.com/rswag/rswag#enable-auto-generation-examples-from-responses
Anyway thanks : )
it's just my project's settings problem, or may I create a PR to add this description? @salzig

@kevinluo201 when i remember correctly, and it's quite a while ago, the task definitivtions where quite clear about this. So in the end i read the code. :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Kutomore picture Kutomore  Â·  3Comments

ManevilleF picture ManevilleF  Â·  4Comments

abevoelker picture abevoelker  Â·  4Comments

martio picture martio  Â·  4Comments

nicwillemse picture nicwillemse  Â·  4Comments