No commit activity in last 3 years
No release in over 3 years
Rails generator to build Swagger UI API doc viewer
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.5
>= 3.1
>= 0

Runtime

 Project Readme

Swagger UI Generator

Rails generator to add Swagger UI API documentation to your application.

Swagger UI is a dependency-free collection of HTML, Javascript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API.

Usage

Run the generator to create the Swagger UI structure:

rails generate swagger_ui_generator:install

By default, Swagger UI will be created at public/api-docs.html, and all the assets will be created in the public/swagger folder. It will expect the root swagger definition file to be accessible at: /swagger/api-docs.json from your rails server. If you use swagger-docs to dynamically generate the API spec files, you can use an initializer something like:

endpoints = {
  "production"  => "http://api.my-service.com",
  "staging"     => "http://api-staging.my-service.com",
  "development" => "http://localhost:3000",
}

Swagger::Docs::Config.register_apis({
  "1.0" => {
    api_extension_type:  :json,
    api_file_path:       "public/swagger/",
    base_path:           "#{ endpoints[Rails.env] }",
    clean_directory:     true
  }
})

class Swagger::Docs::Config
  def self.transform_path(path)
    "swagger/#{ path }"
  end
end

This will create api-docs.json and an additional spec file per endpoint in the public/swagger directory.

Installation

Add this line to your application's Gemfile:

gem 'swagger_ui_generator'

And then execute:

$ bundle

Or install it yourself as:

$ gem install swagger_ui_generator

Contributing

  1. Fork it ( http://github.com//swagger_ui_generator/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request