New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More

swagger-ui

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

swagger-ui

0.0.2
Version published
Maintainers
2
Created

Swagger

Rails wrapper for the Swagger-UI API

Installation

Add this line to your application's Gemfile:

gem 'swagger-ui', :require => 'swagger'

And then execute:

$ bundle

Then run the generator:

$ rails generate swagger:install

Usage

Check out index.html.haml in the examples for basic setup. A docs controller and routes will also be required. Fill out the api in the docs controller. Example:

class Api::DocsController < Api::ApiController
  include Swagger

  def index
    document = {
      "swaggerVersion" => "1.1",
      "basePath" => api_docs_url,
      "apis" => [
        {"path" => "/foo",
         "description" => ""}]
    }
    render :json => document
  end

  def foo
    document(api_url, :resourcePath => 'foos') do |doc|
      doc.api('/foos') do |api|
        api.operations(['GET','POST']) do |op|
          op.param('param', :required => true)
        end
      end
    end
  end
end

Contributing

  • 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

FAQs

Package last updated on 14 Feb 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts