module Rack::Swagger

Constants

VERSION

Public Class Methods

app(docs_dir, opts={}) click to toggle source

Rack app for serving the swagger-ui front-end and your JSON-formatted Swagger doc files.

Description:

The app will serve the swagger-ui front-end at /docs/, and redirect
requests for /docs to /docs/. It will serve the root Swagger doc
file at /docs/api-docs, and resource files in a subpath of /docs/api-docs,
such as /docs/api-docs/pet for the "pet" resource. This mimics the way
the Pet Store demo is set up.

See: http://petstore.swagger.wordnik.com/

Parameters:

docs_dir: a String containing the path to the directory with your root
Swagger JSON doc file (called swagger.json) and all resource-specific
doc files (for example, pet.json for the "pet" resource).

Usage:

In your config.ru, add:

run Rack::Swagger.app(File.expand_path("../docs/", __FILE__))
# File lib/rack/swagger.rb, line 33
def self.app(docs_dir, opts={})
  Rack::Cascade.new([
    JsonServer.new(docs_dir, opts),
    IndexPageServer.new,
    AssetServer.new
  ])
end