1 | initial version |
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.