-
Notifications
You must be signed in to change notification settings - Fork 4
Request Response Examples
drinor edited this page Mar 30, 2013
·
1 revision
Rapidoc lets you load examples of requests and responses. Each resource can have one request and one response example that will be showed in the resource page. Each one has a tab where you can see the example.
For now, rapidoc only supports json formats.
The files name must be the next format:
<resource>_<action>_<type>.json
- resource: name of resource agrupation (controller)
- action: type of action for this resource
- type: request/response
If you have an user resource:
GET /users(.:format) users#index
GET /users/:id(.:format) users#show
POST /users(.:format) users#create
The examples files must be named:
users_index_response.json
users_show_response.json
users_create_request.json
users_create_response.json
The examples_route parameter let you specify where rapidoc will search for requests/responeses examples files.
- If you don't use this parameter, rapidoc uses default examples_route:
path_project/config/rapidoc/examples
- If you add examples_route: my_path to config file, rapidoc uses the next route:
path_project/my_path
If final directory from the route doesn't exists, rapidoc creates this directory.
This is an example of file content ( users_create_request.json ):
{
"user": {
"name": "user name",
"email": "[email protected]"
}
}