Swagui
a Rack middleware app and a command-line utility that helps you render swagger-ui, a great api documentation tool, with ease and grace.
Install
Add this line to your application's Gemfile:
group :development do
gem 'swagui'
end
Usage
Rack middleware
In your application.rb
(for Rails app) or config.ru
(for Rack app), add Swigui middleware close to the top of the middleware stack. For example, in a config.ru
file, add the following line:
if Rack.env == 'development'
use Swagui::App, url: '/doc', path: 'doc'
end
url
: the url path to access the swagger-ui.path
: the sub-directory name where the swagger files are stored. It assumes thatapi-docs
is the index file in the directory.- basic auth block: in case the doc site need to be protected by http basic auth, you can configure it by a block, for example:
use Swagui::App, url: '/doc', path: 'doc' do |username, password|
[username, password] == ['admin', 'admin']
end
You will be able to access the swagger-ui loaded with your api documentation at /doc
(your url
setting) when the server starts.
Command-line utility
Sometimes, you only want to see the documentation without starting the entire application. All you need to do is to run the following command in your documentation directory:
$ bundle exec swagui
optionally, you can specify the directory name as a command line argument:
$ bundle exec swagui doc
You will then able to view the swagger-ui loaded with your api documentation at http://localhost:9292
Contributing
- Fork it ( https://github.com/jackxxu/swagui/fork )
- 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 a new Pull Request