/api_yard_parser

Parse for yard docs and show API description

Primary LanguageRubyMIT LicenseMIT

ApiYardParser

This project rocks and uses MIT-LICENSE.

Developed in Locaweb by Thiago Coutinho. www.locaweb.com.br

1. REQUIREMENTS

Ruby/ApiYardParser requires Ruby version 1.9.1 or newer and Rails ~> 3.2.16.

2. INSTALLATION

Add to Gemfile:

gem 'api_yard_parser'

After… in prompt…

bundle install

Try.…

localhost:XXXX/docs

3. Examples

For your controller add the yard doc:

class ApiController < ApplicationController

  # Infos of domain
  # @note 
  #   [ Receive parameters from GET]
  #     https://{APP_URL}/api/:domain
  #
  # @param [String] :domain => Domain name
  # @return [JSON] Response HTTP 412 - Precondition Failed -> Parameters not valid  
  # @return [JSON] Response HTTP 500 - Internal error 
  # @return [JSON] Response HTTP 200 - Show -> Info of domain
  #
  #      {
  #          "domain": "something.com",
  #      }
  def infos
  ...
  end

end

or.…..

class ApiController < ApplicationController

  # Toggle status of alias from domain
  # @type PUT
  # @url https://:APP_URL/domains/:domain/toggle
  #
  # @param [String] domain       -> Name of domain. Parameter in url
  #
  # @return [JSON] Response HTTP 201 - Ok -> Updated
  #
  #    {
  #        "domain": "msf.com",
  #        "status": "enabled"
  #    }
  #
  # @return [JSON] Response HTTP 404 - Not Found -> Domain doesn't exists
  # @return [JSON] Response HTTP 404 - Not Found -> Alias doesn't exists
  # @return [JSON] Response HTTP 500 - Internal server error
  def toggle_status
  ...
  end

end