Skip to content

Action Documentation

Rafael Jurado González edited this page May 6, 2013 · 11 revisions

For get action documentation you need add an action block to resource controller:

# =begin action
#  ...
# =end

If you use controllers_route config (.yml files):

# =begin action
...
# =end

Documentation blocks use yaml format.

Params

You need add parameters to action blocks that will be interpreted by rapidoc and used for generate documentation of actions.

  • method
  • action
  • authentication_required
  • response_formats
  • description
  • http_responses
  • params
  • errors

method

method: GET
  • Type: String
  • Description: method for access to acction
  • Values: the most common are: GET, POST, PUT and DELETE
  • Required: true

action

action: index
  • Type: String
  • Description: action called for this method + url
  • Values: the most common are: index, show, create, update and destroy
  • Required: true

authentication_required

authentication_required: true
  • Type: Boolean
  • Description: indicates if this action requires authentication
  • Values: [true, false]
  • Required: false

If you don't add this paramether, rapidoc use default value (true). For change default value see: configuration

response_formats

response_formats: json, html
  • Type: String
  • Description: types of formats that your API support
  • Values: the most commont are: json, xml and html
  • Required: false

You can omit this parameter if you use default response formats. For define default response formats see: configuration

description

description: returns all users
  • Type: String
  • Description: action description
  • Required: false

For multi line description use > operator.
If you use inline description and want use the character : you need surround description with ''.

http_responses

http_responses:
  - 204
  - 403
  - 404
  • Type: Array
  • Description: http status codes that this resouece can return
  • Values: the most commont are: 200, 201, 401, 404, 422...
  • Required: false

params

params:
  - name: email
    description: user email
    type: String
  • Type: Array
  • Description: all params that you can use in request
  • Required: false

For more info about params see: params

errors

params:
  - object: email
    message: invalid
    description: invalid email format
  • Type: Array
  • Description: all errors that request can returns
  • Required: false

For more info about errors see: errors

Example

For complete example see the user tests controller: complete example

Clone this wiki locally