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: 'adammartak/rack-swagger-ui'
And then execute:
$ bundle
Or install it yourself as:
$ gem install rack-swagger-ui
Add middleware to your config.ru:
require 'rack-swagger-ui'
use Rack::Static,
urls: ['/js', '/css', '/fonts', '/images'],
root: File.join(Rack::Swagger::Ui.root, 'public')
run Rack::Swagger::Ui::Controller
and configure your grape:
class YourAPI < Grape::API
version 'v1'
format :json
...
add_swagger_documentation :add_version => true,
:base_path => '/api'
end
See https://github.com/ruby-grape/grape-swagger#configure for more configuration settings.
If your api path is "api/v1" just go to
http://host:port/api/doc
- 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