[BUG] `rswag:specs:swaggerize` does not respect `rswag_dry_run` set in RSpec config
stevegeek opened this issue · 4 comments
Describe the bug
The rake task rswag:specs:swaggerize
checks Rswag::Specs.config.rswag_dry_run
to determine if --dry-run
should be used.
However, if Im not mistaken, this check happens before an application's test/RSpec configuration has even been parsed so all the Rswag configuration values that are proxied from RSpec configuration will always be nil.
Steps to Test or Reproduce
Follow docs and add to test.rb
:
RSpec.configure do |config|
config.rswag_dry_run = false
end
Run rake task, notice that it is not observed as test.rb
is not loaded till later.
Expected behavior
Documentation implies I should expect to not run a dry run, but rswag_dry_run
is always nil at the point of the check
Screenshots
Eg adding a couple of log lines:
$ rails rswag:specs:swaggerize
** Checking Rswag::Specs.config.rswag_dry_run in rake task
<snip>/rspec-core-3.12.2/exe/rspec --pattern spec/requests/\*\*/\*_spec.rb,\ spec/api/\*\*/\*_spec.rb,\ spec/integration/\*\*/\*_spec.rb --format Rswag::Specs::OpenapiFormatter --dry-run --order defined
** Setting RSpec.config.rswag_dry_run
Generating OpenAPI spec...
...
Additional context
Add any other context about the problem here.
Dependency versions
The version of are you using for:
- Rswag: 2.10.1
- RSpec: 3.12.2
- Rails: 7.0.8
- Ruby: 3.2.2
That config variable is supposed to be swagger_dry_run
not rswag_dry_run
that's probably your problem.
If you check this, you can see you've got the variable name wrong..
@perfetti right sorry, you are correct in the case of the main branch, but this config has been renamed in v3 (see #574). I've been working off that branch for a while now and completely forgot it had a different name before!
See:
I believe the problem still stands, even with the v2 naming. I will double check when I get a second and update this issue.
I assume the problem is as described, that setting this value in your swagger/openapi spec helper wont help as that wont be evaluated yet at the point the rake task is running
@stevegeek, see #359 (comment)
@romanblanco ok thanks!