Skip to content

Instantly share code, notes, and snippets.

@phonyphonecall
Created July 7, 2014 03:19
Show Gist options
  • Save phonyphonecall/4a6bdc9d3a8539862b05 to your computer and use it in GitHub Desktop.
Save phonyphonecall/4a6bdc9d3a8539862b05 to your computer and use it in GitHub Desktop.
Notification-service RAML
#%RAML 0.8
title: Notification Service
version: v0.1
baseUri: http://server/api/{version}
schemas:
- notification: |
{ "$schema": "http://json-schema.org/schema",
"type": "object",
"description": "A notification",
"properties": {
"notification_id" : { "type" : "number", "required" : "true" },
"from": { "type": "number", "required" : "true"},
"title" : {"type" : "string", "required" : "true"},
"body" : {"type" : "string"},
"timeS_sent" : {"type" : "string", "required" : "true"}
}
}
- authenticationFailed: |
{ "$schema": "http://json-schema.org/schema",
"type": "object",
"description": "Authentication Failed",
"properties": {
"info": { "type": "string", "required" : "false"}
}
}
- userNotFound: |
{ "$schema": "http://json-schema.org/schema",
"type": "object",
"description": "User Not Found",
"properties": {
"info": { "type": "string", "required" : "false"}
}
}
- user: |
{
"$schema" : "http://json-schema.org/schema",
"type" : "object",
"description" : "A user",
"properties" : {
"user_id" : {
"type" : "number",
"required" : "true"
},
"user_name" : {
"type" : "string",
"required" : "true"
},
"groups" : {
"description" : "an array of groupId's the user belongs to",
"type" : "array",
"items" : {
"type" : "number"
}
},
"date_joined":{
"type" : "string",
"required" : "true"
}
}
}
- group: |
{
"$schema":"http://json-schema.org/schema",
"type":"object",
"description":"A group",
"properties":{
"group_id":{
"type":"number",
"required":"true"
},
"group_name":{
"type":"string",
"required":"true"
},
"date_created":{
"type":"string",
"required":"true"
},
"users" : {
"description" : "users in this group",
"type" : "array",
"items" : {
"type" : "number", "description" : "user_id's of users in this group"
}
}
}
}
/notifications:
displayName: notifications
get:
description: get all notifications
queryParameters:
userId:
displayName: userId
description: user to lookup notifications for
type: number
required: true
responses:
200:
body:
application/json:
400:
body:
application/json:
schema: authenticationFailed
404:
body:
application/json:
schema: userNotFound
post:
description: Create a new notifications
queryParameters:
from:
displayName: from
description: Who is this notification from
type: number
required: true
to:
displayName: to
description: What groupId is this notifications to
type: number
required: true
title:
displayName: title
description: What is the title of this notifications
type: string
required: true
body:
displayName: body
description: Any content of the notifications
type: string
required: false
responses:
200:
body:
application/json:
/{notification_id}:
displayName: notification_id
get:
description: get notification by notification_id
responses:
200:
body:
application/json:
schema: notification
/users:
displayName: users
get:
description: Look up user by user_name
queryParameters:
username:
description: user_name to look up
type: string
required: true
responses:
200:
body:
application/json:
schema: user
400:
description: "requires at least one query param"
404:
body:
application/json:
schema: userNotFound
post:
description: create a new user
queryParameters:
username:
description: username for the new user
type: string
required: true
responses:
200:
body:
application/json:
schema: user
404:
description: user not found
409:
description: Username is taken
/{user_id}:
displayName: user_id
get:
description: get user by user_id
responses:
200:
description: found user by user_id
body:
application/json:
schema: user
404:
description: user not found
/groups:
displayName: groups
post:
description: create a new group
queryParameters:
group_name:
description: "name of group to create"
type: "string"
required: "true"
responses:
200:
body:
application/json:
schema: group
409:
description: group name already exists
/{group_id}:
displayName: group_id
get:
description: get a group
responses:
200:
body:
application/json:
schema: group
409:
description: group not found
/users:
displayName: users
get:
description: get all users of a group
responses:
200:
body:
application/json:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment