mirror of
https://github.com/ditkrg/rswag.git
synced 2026-01-25 07:16:40 +00:00
Support mount-specific swagger_root and add swagger_filter setting
This commit is contained in:
@@ -1,16 +1,14 @@
|
||||
SwaggerRails.configure do |c|
|
||||
|
||||
# Define your swagger documents and provide any global metadata here
|
||||
# (Individual operations are generated from your spec/test files)
|
||||
c.swagger_doc 'v1/swagger.json',
|
||||
{
|
||||
swagger: '2.0',
|
||||
info: {
|
||||
title: 'API V1',
|
||||
version: 'v1'
|
||||
}
|
||||
}
|
||||
# Specify a root folder where Swagger JSON files are located
|
||||
# This is used by the Swagger middleware to serve requests for API descriptions
|
||||
# NOTE: If you're using the rspec DSL to generate Swagger, you'll need to ensure
|
||||
# that the same folder is also specified in spec/swagger_helper.rb
|
||||
c.swagger_root = Rails.root.to_s + '/swagger'
|
||||
|
||||
# Specify a location to output generated swagger files
|
||||
c.swagger_dir File.expand_path('../../../swagger', __FILE__)
|
||||
# Inject a lamda function to alter the returned Swagger prior to serialization
|
||||
# The function will have access to the rack env for the current request
|
||||
# For example, you could leverage this to dynamically assign the "host" property
|
||||
#
|
||||
#c.swagger_filter = lambda { |swagger, env| swagger['host'] = env['HTTP_HOST'] }
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user