diff --git a/examples/11. Resource Model.md b/examples/11. Resource Model.md index 1b6c4fe..7b898a0 100644 --- a/examples/11. Resource Model.md +++ b/examples/11. Resource Model.md @@ -6,8 +6,9 @@ Resource model is a [resource manifestation](http://www.w3.org/TR/di-gloss/#def- Furthermore, in API Blueprint, any `resource model` you have defined can be referenced in a request or response section, saving you lots of time maintaining your API blueprint. You simply define a resource model as any payload (e. g. [request](https://github.com/apiaryio/api-blueprint/blob/master/examples/06.%20Requests.md) or [response](https://github.com/apiaryio/api-blueprint/blob/master/examples/5.%20Responses.md)) and then reference it later where you would normally write a `request` or `response`. ## API Blueprint -+ [Previous: Advanced Attributes](09.%20Advanced%20Attributes.md) ++ [Previous: Data Structures](10.%20Data%20Structures.md) + [This: Raw API Blueprint](https://raw.github.com/apiaryio/api-blueprint/master/examples/10.%20Resource%20Model.md) ++ [Next: Inline Action](12.%20Inline%20Action.md) # Group Messages Group of all messages-related resources. diff --git a/examples/12. Inline Action.md b/examples/12. Inline Action.md new file mode 100644 index 0000000..cd09c35 --- /dev/null +++ b/examples/12. Inline Action.md @@ -0,0 +1,66 @@ +FORMAT: 1A + +# Inline Action API +This API example demonstrates that a resource can contain an in-place definition of another resource. This allows us to show that the resource `Task` can afford an action that is not limited to the resource `Task`. + +## API Blueprint ++ [Previous: Resource Model](11.%20Resource%20Model.md) ++ [This: Raw API Blueprint](https://raw.github.com/apiaryio/api-blueprint/master/examples/11.%20Inline%20Action.md) + +# Task [/tasks/{id}] + ++ Parameters + + id (string) + +## Retrieve Task [GET] + ++ Response 200 (application/json) + + { + "id": 123, + "name": "Go to gym", + "done": false, + "type": "task" + } + +## Update Task [PATCH] +This is a state transition within the same resource + ++ Request (application/json) + + { + "name": "Exercise in gym" + } + ++ Response 200 (application/json) + + { + "id": 123, + "name": "Exercise in gym", + "done": false, + "type": "task" + } + +## List All Tasks [GET /tasks{?status,priority}] +This is a state transition to another resource + ++ Parameters + + status (string) + + priority (number) + ++ Response 200 (application/json) + + [ + { + "id": 123, + "name": "Exercise in gym", + "done": false, + "type": "task" + }, + { + "id": 123, + "name": "Shop for groceries", + "done": true, + "type": "task" + } + ]