Support mount-specific swagger_root and add swagger_filter setting

This commit is contained in:
richie
2016-06-29 16:11:40 -07:00
parent 60f33a5386
commit 7a01babe01
30 changed files with 367 additions and 144 deletions

View File

@@ -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