Integrates swagger-ui with your "grapified" Rack application.
Add swagger compliant documentation to your grape API
An opinionated micro-framework for creating REST-like APIs in Ruby
Add this line to your application's Gemfile:
gem 'rack-swagger-ui', github: 'BrandyMint/rack-swagger-ui'
And then execute:
$ bundle
Or install it yourself as:
$ gem install rack-swagger-ui
Configure your grape:
class YourAPI < Grape::API
version 'v1'
format :json
...
add_swagger_documentation
end
Add middleware to your config.ru:
require 'rack-swagger-ui'
use Rack::Static,
urls: ['/javascripts', '/stylesheets', '/images'],
root: File.join(Rack::Swagger::Ui.root, 'public')
map '/swagger' do
run Rack::Swagger::Ui::Controller.new
end
# OR
run Rack::Cascade.new([YourAPI.new,
Rack::Swagger::Ui::Controller.new('/swagger')])
See https://github.com/ruby-grape/grape-swagger#configure for more configuration settings.
The Swagger UI page will be located at
http://host:port/swagger
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
MIT License, full text of license see here