Module moonwalk.api.operation
API operation.
Extends the proto object.
Functions
constructor ([docstring], fn) | Create an operation. |
decode_docblock (name, api) | Decode docblock for function. |
prepare (connection) | Finds an appropriate operation to handle a request. |
Fields
use_markdown | Use Markdown to format the "notes" section of the doc block. |
summary_format | Format string for the "summary" section of a doc block. |
notes_format | Format string for the "notes" section of a doc block. |
Functions
- constructor ([docstring], fn)
-
Create an operation. This function is not meant to be called directly
(see proto.constructor ).
Parameters:
- docstring string A string documenting the function, as described in the readme.
- fn optional function A function to handle this operation.
- decode_docblock (name, api)
-
Decode docblock for function.
Parameters:
- name
The name of the API operation function.
This becomes the Swagger
nickname
. - api The api this operation belongs to.
Returns:
- The resource path (as defined by the @path tag).
- A table containing the API declaration .
- A table containing any referenced models.
- name
The name of the API operation function.
This becomes the Swagger
- prepare (connection)
-
Finds an appropriate operation to handle a request.
Extracts arguments from the request, and validates them based on the API author's validation rules. Modifies the request table with information about the extracted arguments if validation succeeds.
no operation was found.
Parameters:
- connection A connection instance.
Returns:
- A function to handle the operation, defined by the API author.
-
A numeric table of arguments, with a
length
property to accomodate sparseness. - A validator.failure instance if validation failed or
Fields
- use_markdown
-
Use Markdown to format the "notes" section of the doc block.
Defaults to
true
. - summary_format
-
Format string for the "summary" section of a doc block.
Replacement tokens:
{nickname}
,{summary}
,{notes}
- notes_format
-
Format string for the "notes" section of a doc block.
Replacement tokens:
{nickname}
,{summary}
,{notes}