swagger: upvote and downvote post endpoints

master
ALI Hamza 2020-09-10 20:52:27 +07:00
parent ec3f69a323
commit bf9528ad2b
Signed by: hamza
GPG Key ID: 22473A32291F8CB6
1 changed files with 79 additions and 0 deletions

@ -195,6 +195,8 @@ paths:
- Post Endpoints - Post Endpoints
security: security:
- token: [ ] - token: [ ]
summary: Create a new post
description: This endpoint will take information that new posts require and then create a new entry that will be submitted to the website.
requestBody: requestBody:
description: Submit a new post with this endpoint. description: Submit a new post with this endpoint.
required: true required: true
@ -235,6 +237,8 @@ paths:
get: get:
tags: tags:
- Post Endpoints - Post Endpoints
summary: Get information fora post.
description: Returns the post information and all comments for a particular post.
parameters: parameters:
- name: id - name: id
in: path in: path
@ -259,6 +263,68 @@ paths:
type: array type: array
items: items:
$ref: '#/components/schemas/Comment' $ref: '#/components/schemas/Comment'
404:
$ref: '#/components/responses/NotFound'
500:
$ref: '#/components/responses/ServerError'
/post/{id}/upvote:
post:
tags:
- Post Endpoints
summary: Upvote a post
description: Add an upvote to a specified post. If you have already upvoted a point, it is retracted.
security:
- token: []
parameters:
- name: id
in: path
required: true
description: The post ID to upvote.
schema:
type: string
responses:
200:
description: Your upvote has successfully been registered.
content:
application/json:
schema:
type: object
401:
$ref: '#/components/responses/InvalidToken'
404:
$ref: '#/components/responses/NotFound'
500:
$ref: '#/components/responses/ServerError'
/post/{id}/downvote:
post:
tags:
- Post Endpoints
summary: Downvote a post
description: Add an downvote to a specified post. If you have already downvoted a point, it is retracted.
security:
- token: []
parameters:
- name: id
in: path
required: true
description: The post ID to downvote.
schema:
type: string
responses:
200:
description: Your downvote has successfully been registered.
content:
application/json:
schema:
type: object
401:
$ref: '#/components/responses/InvalidToken'
404:
$ref: '#/components/responses/NotFound'
500:
$ref: '#/components/responses/ServerError'
components: components:
parameters: parameters:
@ -341,6 +407,15 @@ components:
example: example:
reason: The token provided is invalid. reason: The token provided is invalid.
code: 401 code: 401
NotFound:
description: The requested resource was not found.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
reason: The specified resource does not exist.
code: 404
Unprocessable: Unprocessable:
description: The request was valid, however some of the parameters have an invalid value. description: The request was valid, however some of the parameters have an invalid value.
content: content:
@ -419,6 +494,7 @@ components:
- title - title
- upvotes - upvotes
- downvotes - downvotes
- comments
- date_created - date_created
properties: properties:
id: id:
@ -439,6 +515,9 @@ components:
downvotes: downvotes:
description: The number of downvotes a post has. description: The number of downvotes a post has.
type: integer type: integer
comments:
description: The number of comments available on a post.
type: integer
date_created: date_created:
description: The time at which this post was submitted. description: The time at which this post was submitted.
type: string type: string