Skip to content

Instantly share code, notes, and snippets.

@cazala
Created April 14, 2015 20:01
Show Gist options
  • Save cazala/323985cdc07c542716d9 to your computer and use it in GitHub Desktop.
Save cazala/323985cdc07c542716d9 to your computer and use it in GitHub Desktop.
API Template: RAML Endpoint
# replace {{resource}} by the name of the resource
# replace {{secured}} by the appropiate authorization trait name, i.e. 'secured', 'auth', etc...
traits:
- {{secured}}:
queryParameters:
# authorization query params
headers:
# authorization headers
schemas:
- {{resource}}: |
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
# schema properties
},
"required": [
# required properties
],
"additionalProperties": false
}
/{{resource}}:
get:
description: Lists the {{resource}}s associated with the agent
is: ['{{secured}}']
responses:
200:
body:
application/json:
example: |
{
"data": {
"{{resource}}s":[
# example resource list
]
},
"isSuccessful": true,
"message": ""
}
401:
body:
application/json:
example: |
{
"data": {},
"isSuccessful": false,
"message": "Invalid token"
}
500:
body:
application/json:
example: |
{
"data": {},
"isSuccessful": false,
"message": "Service Unavailable"
}
post:
description: Associates a {{resource}} to a given agent
is: ['{{secured}}']
body:
application/json:
schema: {{resource}}
example: |
{
# example resource
}
responses:
201:
body:
application/json:
example: |
{
"data": {
"id": 1
},
"isSuccessful": true,
"message": ""
}
401:
body:
application/json:
example: |
{
"data": {},
"isSuccessful": false,
"message": "Invalid token"
}
500:
body:
application/json:
example: |
{
"data": {},
"isSuccessful": false,
"message": "Service Unavailable"
}
/{{{resource}}Id}:
get:
description: Returns a given {{resource}}
is: ['{{secured}}']
responses:
200:
body:
application/json:
example: |
{
"data": {
# example resource
},
"isSuccessful": true,
"message": ""
}
401:
body:
application/json:
example: |
{
"data": {},
"isSuccessful": false,
"message": "Invalid token"
}
500:
body:
application/json:
example: |
{
"data": {},
"isSuccessful": false,
"message": "Service Unavailable"
}
put:
description: Updates a given {{resource}} resource
is: ['{{secured}}']
body:
application/json:
schema: {{resource}}
example: |
{
# example resource
}
responses:
200:
body:
application/json:
example: |
{
"data": {},
"isSuccessful": true,
"message": ""
}
401:
body:
application/json:
example: |
{
"data": {},
"isSuccessful": false,
"message": "Invalid token"
}
500:
body:
application/json:
example: |
{
"data": {},
"isSuccessful": false,
"message": "Service Unavailable"
}
delete:
description: Deletes a given {{resource}} resource
is: ['{{secured}}']
responses:
200:
body:
application/json:
example: |
{
"data": {},
"isSuccessful": true,
"message": ""
}
401:
body:
application/json:
example: |
{
"data": {},
"isSuccessful": false,
"message": "Invalid token"
}
500:
body:
application/json:
example: |
{
"data": {},
"isSuccessful": false,
"message": "Service Unavailable"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment