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
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.
# spec/swagger_helper.rb
RSpec.configure do |config|
–
config.swagger_dry_run = false
…
end
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::SwaggerFormatterwill 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. :)
Most helpful comment
Running
be rspec spec/integration/ --format documentation --format Rswag::Specs::SwaggerFormatterwill run the tests, and additionally generate the swagger doc.it seems the --dry-run option is not necessary, as the specs wont run nonetheless.