Skip to content

Commit

Permalink
Added docs
Browse files Browse the repository at this point in the history
  • Loading branch information
shabda committed Mar 15, 2018
1 parent 162c19b commit 7a60f5d
Show file tree
Hide file tree
Showing 2 changed files with 336 additions and 0 deletions.
176 changes: 176 additions & 0 deletions pollsapi/docs.raml
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
#%RAML 1.0
---
title: Django polls API
baseUri: http://api.example.com/{version}
version: v1
mediaType: application/json
types:
Poll:
type: object
properties:
question:
required: true
type: string
created_by:
required: true
type: User
pub_date:
required: true
type: date
Choice:
type: object
properties:
poll:
required: true
type: Poll
choice_text:
required: true
type: string
Vote:
type: object
properties:
choice:
required: true
type: Choice
poll:
required: true
type: Poll
voted_by:
required: true
type: User
/polls:
get:
description: Get list of polls
queryParameters:
pollId:
description: Specify the poll id you want to retrieve
type: integer
responses:
200:
body:
application/json:
example:
{
"data":
{
"Id": 1,
"question": "Will A be the leader next time?",
"created_by": "user1",
"pub_date": "08:02:2014"
},
"success": true,
"status": 200
}
post:
description: Post a poll
queryParameters:
question:
description: Question you want to create for poll
type: string
required: true
created_by:
description: Poll created by the user
type: User
required: true
pub_date:
description: Poll created on
type: date
required: true
responses:
200:
body:
application/json:
example:
{
"success": true,
"status": 201
}
/choices:
get:
description: Get list of choices
queryParameters:
choiceId:
description: Specify the choice id you want to retrieve
type: integer
responses:
200:
body:
application/json:
example:
{
"data":
{
"Id": 1,
"poll": "Will A be the leader next time?",
"choice_text": "user1"
},
"success": true,
"status": 200
}
post:
description: Post a choice
queryParameters:
poll:
description: Choice you want to create for poll
type: string
required: true
choice_text:
description: Choice for the poll
type: string
required: true
responses:
200:
body:
application/json:
example:
{
"success": true,
"status": 201
}
/votes:
get:
description: Get votes of polls
queryParameters:
pollId:
description: Specify the vote id you want to retrieve
type: integer
responses:
200:
body:
application/json:
example:
{
"data":
{
"Id": 1,
"poll": "Will A be the leader next time?",
"choice": "user1",
"voted_by": "user2"
},
"success": true,
"status": 200
}
post:
description: Post a vote
queryParameters:
choice:
description: Choice for the poll
type: Choice
required: true
poll:
description: Poll to be voted
type: Poll
required: true
voted_by:
description: Poll voted by
type: User
required: true
responses:
200:
body:
application/json:
example:
{
"success": true,
"status": 201
}
160 changes: 160 additions & 0 deletions pollsapi/docs.swagger.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
{
"swagger": "2.0",
"info": {
"description": "This is a sample server for polls api.",
"version": "1.0.0",
"title": "Polls API",
"termsOfService": "http://example.com/terms/",
"contact": {"email": "apiteam@example.com"},
"license": {"name": "Apache 2.0", "url": "http://www.apache.org/licenses/LICENSE-2.0.html"}
},
"host": "polls.example.com",
"basePath": "/v2",
"tags": [
{
"name": "polls",
"description": "Everything about your Polls",
"externalDocs": {"description": "Find out more","url":"http://example.com"}
},
{
"name": "choices",
"description": "Access to choices for the polls"
},
{
"name": "user",
"description": "Operations about user",
"externalDocs": {"description": "Find out more about our store","url":"http://example.com"}
}
],
"schemes": ["http"],
"paths": {
"/polls": {
"get": {
"tags": ["poll"],
"summary": "Get all the polls",
"description": "",
"operationId": "pollList",
"consumes": ["application/json","application/xml"],
"produces": ["application/xml","application/json"],
"parameters": [{
"in": "query",
"name": "body",
"description": "Get all the polls.",
"required": false,
"schema":{"$ref":"#/pollsapi/Poll"}
}],
"responses": {"200":{"description":"Successfull operation"}},
},
"post":{
"tags": ["poll"],
"summary": "Create a new poll",
"description": "Creates a new poll.",
"operationId": "createPoll",
"consumes":["application/json","application/xml"],
"produces":["application/xml","application/json"],
"parameters":[{
"in":"query",
"name":"body",
"description": "Poll object that needs to be added.",
"required": true,
"schema": {"$ref":"#/pollsapi/Poll"}
}],
"responses": {
"200": {"description":"Poll created successfully"}
}
}
},
"/choices": {
"get": {
"tags": ["choice"],
"summary": "Get all the choices",
"description": "",
"operationId": "choiceList",
"consumes": ["application/json","application/xml"],
"produces": ["application/xml","application/json"],
"parameters": [{
"in": "query",
"name": "body",
"description": "Get all the choices.",
"required": false,
"schema":{"$ref":"#/pollsapi/Choice"}
}],
"responses": {"200":{"description":"Successfull operation"}},
},
"post":{
"tags": ["choice"],
"summary": "Create a new choice",
"description": "Creates a new choice.",
"operationId": "createChoice",
"consumes":["application/json","application/xml"],
"produces":["application/xml","application/json"],
"parameters":[{
"in":"query",
"name":"body",
"description": "Choice object that needs to be added.",
"required": true,
"schema": {"$ref":"#/pollsapi/Poll"}
}],
"responses": {
"200": {"description":"Poll created successfully"}
}
}
},
"/user": {
"get": {
"tags": ["user"],
"summary": "Get user details",
"description": "",
"operationId": "user",
"consumes": ["application/json","application/xml"],
"produces": ["application/xml","application/json"],
"parameters": [{
"in": "query",
"name": "body",
"description": "Get the user.",
"required": false,
"schema":{"$ref":"#/pollsapi/User"}
}],
"responses": {"200":{"description":"Successfull operation"}},
},
"post":{
"tags": ["user"],
"summary": "Create a new user",
"description": "Creates a new user.",
"operationId": "createUser",
"consumes":["application/json","application/xml"],
"produces":["application/xml","application/json"],
"parameters":[{
"in":"query",
"name":"body",
"description": "User object that needs to be added.",
"required": true,
"schema": {"$ref":"#/pollsapi/User"}
}],
"responses": {
"200": {"description":"User created successfully"}
}
}
},
"/vote": {
"post":{
"tags": ["vote"],
"summary": "Create a new vote",
"description": "Creates a new vote.",
"operationId": "createVote",
"consumes":["application/json","application/xml"],
"produces":["application/xml","application/json"],
"parameters":[{
"in":"query",
"name":"body",
"description": "Vote object that needs to be added.",
"required": true,
"schema": {"$ref":"#/pollsapi/Vote"}
}],
"responses": {
"200": {"description":"Vote created successfully"}
}
}
}
}
}

0 comments on commit 7a60f5d

Please sign in to comment.