InstaSwag

InstaSwag provides lighting-fast, dynamically generated swagger-documentation for grape APIs

Mounting

Mounting swagger had never been easier. The ::for takes in 2 arguments. The first is your API class that inherits from Grape::API and a hash of settings to customise the swagger documentation. Which returns an instance of Rack::Builder

Sample usage

Given the settings:

# config.ru

settings = { :prefix => "/reports-api" }

run InstaSwag.for(Api, settings)

Will make your documentation available at http://hostname:3000/reports/documentation/index.html

Default values

All the settings passed will be merged with the default values to populate the mounting of the swagger documentation:

# ./lib/insta_swag.rb

def self.for(klass, settings = {})
  settings   = Settings.new klass, settings

  Rack::Builder.new do
    map settings.assets_path, &InstaSwag::AssetsApp
    map settings.prefix_path, &DocumentationApp.create(klass, settings)
    map settings.index_path,  &StaticFiles.create(settings)
  end
end