Ask Your Question
1

Is it possible to have multiple docks in a single project using rswag rails?

asked 2022-05-26 11:00:00 +0000

woof gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2023-02-16 16:00:00 +0000

lakamha gravatar image

Yes, it is possible to have multiple docks in a single project using rswag rails. You can define multiple SwaggerUI endpoints using the swagger_api method in your config/routes.rb file, and then define separate docks for each endpoint in your config/initializers/rswag-api.rb file.

For example, if you want to define two separate endpoints for your API, you could add the following code to your config/routes.rb file:

# Define endpoint for API v1
namespace :api do
  namespace :v1 do
    swagger_api :v1 do
      # SwaggerUI documentation for API v1
    end
  end
end

# Define endpoint for API v2
namespace :api do
  namespace :v2 do
    swagger_api :v2 do
      # SwaggerUI documentation for API v2
    end
  end
end

Then, in your config/initializers/rswag-api.rb file, you can define separate docks for each endpoint:

# Define dock for API v1
Rswag::Api.configure do |config|
  config.swagger_root = Rails.root.to_s + '/swagger/v1'
  config.swagger_dry_run = false
end

# Define dock for API v2
Rswag::Api.configure do |config|
  config.swagger_root = Rails.root.to_s + '/swagger/v2'
  config.swagger_dry_run = false
end

This way, you can have separate SwaggerUI documentation for each endpoint, while still using rswag rails to generate and manage the documentation for each endpoint.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-05-26 11:00:00 +0000

Seen: 15 times

Last updated: Feb 16 '23