rswag/rswag

[BUG] Host with dynamic value

benebrice opened this issue · 1 comments

Describe the bug

Rspec is now checking the host to make the request.

Steps to Test or Reproduce

Mount an engine on a subdomain and define a host without this subdomain -> It won't work.
Nothing special but behaviour changes from 2.5.1 to 2.10.1

Expected behavior

Rswag does not take care of the host and runs specs based on the Rails host.

Additional context

I've created a whole script to handle those on CI deploy to "replace" url and only display the correct one based on the environment.
I used to have host: '$$url$$' and $$url$$ is updated by the CI based on environment variables.
The main idea was to be able to have only the URL for the environment app is deployed. Production URL is only known when accessing the Production webpage (Rswag-UI). You cannot switch from Staging to Production. It's a dedicated webpage for each.
Changes come from this commit a50525d
Actually the metadata[:operation][:host] is never set. Maybe @amiuhle and @romanblanco could help me with some missing configuration somehow?

Dependency versions

The version of are you using for:

  • Rswag: 2.10.1
  • RSpec: 3.12
  • Rails: 6.1.7.6
  • Ruby: 2.7.2

Relates to which version of OAS (OpenAPI Specification)

  • OAS2
  • OAS3
  • OAS3.1

Based on the source request_factory.rb#L218

I managed to use metadata[:operation][:host] via

# spec/swagger_helper.rb
RSpec.configure do |config|
  # ...
  config.before do |example|
    example.metadata[:operation][:host] = 'api.lvh.me'
  end
  # ...
end

I don't know if it's the normal behaviour to expect. 🤷🏻‍♂️