Include swagger-ui as rails engine.
https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md
Add to Gemfile
gem 'swagger_engine'
Add to your config/routes.rb
mount SwaggerEngine::Engine, at: "/api-docs"
authenticate :user do
mount SwaggerEngine::Engine, at: "/api-docs"
end
or
authenticate :user, lambda { |u| u.admin? } do
mount SwaggerEngine::Engine, at: "/api-docs"
end
Set username and password in config/initializers/swagger_engine.rb
:
SwaggerEngine.configure do |config|
config.admin_username = ENV['ADMIN_USERNAME']
config.admin_password = ENV['ADMIN_PASSWORD']
end
Set the path of your json files in a initializer:
#config/initializers/swagger_engine.rb
SwaggerEngine.configure do |config|
config.json_files = {
v1: "lib/swagger/swagger_v1.json",
v2: "lib/swagger/swagger_v2.json"
}
end
lib/swagger/
is a good place to place them..
Use Swagger editor.
This project rocks and uses MIT-LICENSE.