-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #96 from martindale/api-docs
API Documentation
- Loading branch information
Showing
2 changed files
with
121 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
extends layouts/default | ||
|
||
block content | ||
h1 #{config.service.name} API | ||
|
||
h3 Generally | ||
p <strong>Formatting:</strong> All endpoints serve both JSON and HTML, controlled by the <code>Accept</code> header of your request. You can force the formatting of any resource using the <code>format</code> parameter: i.e., append <code>?format=json</code> to any URL to retrieve the underlying resource as JSON. | ||
p <strong>Events:</strong> Any endpoint can be connected to with a WebSocket, and updates to that resource will be served to you as messages. These messages will be formatted as JSON-PATCH arrays, wrapped in JSON-RPC with the method name <code>patch</code>. The <code>channel</code> parameter will correspond to the resource's route. For more information, see <a href="https://github.com/martindale/maki#pubsub">the Maki documentation on PubSub & Messaging</a>. | ||
p All endpoints can also be interacted with via the following HTTP verbs: | ||
pre | ||
code. | ||
query, get: GET | ||
create: POST, PUT | ||
update: PATCH | ||
delete: DELETE | ||
|
||
- var methodMap = { query: 'GET', get: 'GET', create: 'POST', update: 'PATCH', destroy: 'DELETE' } | ||
|
||
.ui.stackable.grid | ||
.four.wide.column | ||
.ui.vertical.fluid.menu | ||
for resource in resources | ||
a.item(href="/api##{resource.plural.toLowerCase()}") | ||
if (resource.options.icon) | ||
i.icon(class="#{resource.options.icon}") | ||
| #{resource.plural} | ||
.twelve.wide.column | ||
.ui.cards | ||
for resource in resources | ||
.ui.fluid.card | ||
.content | ||
.header | ||
if (resource.options.icon) | ||
i.icon(class="#{resource.options.icon}") | ||
a(href="##{resource.plural.toLowerCase()}", name="#{resource.plural.toLowerCase()}") #{resource.plural} | ||
.description #{resource.description} | ||
.description | ||
h4 Paths | ||
table.ui.table | ||
thead | ||
tr | ||
th Operation | ||
th HTTP Method | ||
th Route | ||
tbody | ||
for method in Object.keys(resource.routes) | ||
tr | ||
td #{method} | ||
td #{methodMap[method]} | ||
td #{resource.routes[method]} | ||
|
||
h3 Attributes | ||
table.ui.table | ||
thead | ||
tr | ||
th Name | ||
th Type | ||
th Required? | ||
th Allowed Values | ||
th Default | ||
th Min | ||
th Max | ||
th Validator | ||
tbody | ||
for name in Object.keys(resource.attributes) | ||
- var attribute = resource.attributes[name] | ||
tr | ||
td #{name} | ||
td #{(attribute.type && attribute.type.name) ? attribute.type.name : attribute.type} | ||
td #{attribute.required} | ||
td #{attribute.enum} | ||
td #{attribute.default} | ||
td #{attribute.min} | ||
td #{attribute.max} | ||
td #{attribute.validator} |