swagger: add /post/{id} endpoint, fix semantic/grammatical errors

master
ALI Hamza 2020-09-10 17:48:20 +07:00
parent 407f9e2630
commit a071edec1b
Signed by: hamza
GPG Key ID: 22473A32291F8CB6
1 changed files with 62 additions and 16 deletions

@ -12,7 +12,7 @@ paths:
post: post:
tags: tags:
- Auth Endpoints - Auth Endpoints
summary: Attemps to log in a user with credentials, and returns an access token. summary: Attempts to log in a user with credentials, and returns an access token.
requestBody: requestBody:
$ref: '#/components/requestBodies/AuthCredentials' $ref: '#/components/requestBodies/AuthCredentials'
responses: responses:
@ -25,7 +25,7 @@ paths:
400: 400:
$ref: '#/components/responses/MalformedBody' $ref: '#/components/responses/MalformedBody'
401: 401:
$ref: '#/components/responses/InvalidCredentials' $ref: '#/components/responses/InvalidCredentials'
500: 500:
$ref: '#/components/responses/ServerError' $ref: '#/components/responses/ServerError'
/auth/logout: /auth/logout:
@ -34,10 +34,10 @@ paths:
- Auth Endpoints - Auth Endpoints
summary: Logs out a user, making their access token invalid. summary: Logs out a user, making their access token invalid.
security: security:
- token: [] - token: [ ]
responses: responses:
200: 200:
description: You have successfully logged out, and your token is now invalid. description: You have successfully logged out, and the token used to authenticate the request is now revoked/invalid.
content: content:
application/json: application/json:
schema: schema:
@ -69,8 +69,8 @@ paths:
type: object type: object
400: 400:
$ref: '#/components/responses/MalformedBody' $ref: '#/components/responses/MalformedBody'
401: 422:
$ref: '#/components/responses/InvalidToken' $ref: '#/components/responses/Unprocessable'
500: 500:
$ref: '#/components/responses/ServerError' $ref: '#/components/responses/ServerError'
@ -78,7 +78,7 @@ paths:
get: get:
tags: tags:
- User Endpoints - User Endpoints
summary: Get the information for a user. summary: Get information for a user.
parameters: parameters:
- name: username - name: username
required: true required: true
@ -108,7 +108,7 @@ paths:
- $ref: '#/components/parameters/BeforeParam' - $ref: '#/components/parameters/BeforeParam'
- $ref: '#/components/parameters/LimitParam' - $ref: '#/components/parameters/LimitParam'
- $ref: '#/components/parameters/CountParam' - $ref: '#/components/parameters/CountParam'
summary: Get the list of posts a user has created/submitted. summary: Get a list of posts a user has created/submitted.
responses: responses:
200: 200:
description: A list of posts filtered and formatted. description: A list of posts filtered and formatted.
@ -140,7 +140,7 @@ paths:
- $ref: '#/components/parameters/BeforeParam' - $ref: '#/components/parameters/BeforeParam'
- $ref: '#/components/parameters/LimitParam' - $ref: '#/components/parameters/LimitParam'
- $ref: '#/components/parameters/CountParam' - $ref: '#/components/parameters/CountParam'
summary: Get the list of comments a user has submitted. summary: Get a list of paginated comments a user has submitted.
responses: responses:
200: 200:
description: A list of comments filtered and formatted. description: A list of comments filtered and formatted.
@ -159,7 +159,9 @@ paths:
/posts: /posts:
get: get:
summary: Get a list of posts tags:
- Post Endpoints
summary: Get a list of paginated posts
description: The items retrieved will always show newest first. description: The items retrieved will always show newest first.
parameters: parameters:
- name: filter - name: filter
@ -192,7 +194,7 @@ paths:
tags: tags:
- Post Endpoints - Post Endpoints
security: security:
- token: [] - token: [ ]
requestBody: requestBody:
description: Submit a new post with this endpoint. description: Submit a new post with this endpoint.
required: true required: true
@ -228,6 +230,36 @@ paths:
$ref: '#/components/responses/Unprocessable' $ref: '#/components/responses/Unprocessable'
500: 500:
$ref: '#/components/responses/ServerError' $ref: '#/components/responses/ServerError'
/post/{id}:
get:
tags:
- Post Endpoints
parameters:
- name: id
in: path
required: true
description: The post ID to retrieve information about
schema:
type: string
responses:
200:
description: Information regarding a post
content:
application/json:
schema:
type: object
allOf:
- $ref: '#/components/schemas/Post'
- type: object
required:
- comments
properties:
comments:
type: array
items:
$ref: '#/components/schemas/Comment'
components: components:
parameters: parameters:
AfterParam: AfterParam:
@ -249,7 +281,7 @@ components:
LimitParam: LimitParam:
name: limit name: limit
in: query in: query
description: Maximimum number of items to return description: Maximum number of items to return
schema: schema:
type: integer type: integer
maximum: 100 maximum: 100
@ -319,7 +351,7 @@ components:
reason: Varies reason: Varies
code: 422 code: 422
ServerError: ServerError:
description: The server could not complete a request due to an unknown error. More information may be available in the description. description: The server could not complete a request due to an unknown error. More information may be available in the 'reason' parameter.
content: content:
application/json: application/json:
schema: schema:
@ -336,13 +368,13 @@ components:
- password - password
properties: properties:
username: username:
description: A Unique uusername to identify a user around the website. description: A unique username to identify a user around the website.
type: string type: string
minLength: 3 minLength: 3
maxLength: 16 maxLength: 16
pattern: "[a-zA-Z0-9 ]{3,16}" pattern: "[a-zA-Z0-9 ]{3,16}"
email: email:
description: A Unique email used for communication/further identification. description: A unique email used for communication/further identification.
type: string type: string
format: email format: email
password: password:
@ -357,6 +389,20 @@ components:
- username - username
- points - points
- date_created - date_created
properties:
id:
type: string
description: The unique ID of the user
username:
type: string
description: The username of the user
points:
type: number
description: The number of points (sum of upvotes and downvotes) of a user
date_created:
type: string
format: 'date-time'
description: When the user's account was created
Token: Token:
required: required:
- token - token
@ -448,4 +494,4 @@ components:
securitySchemes: securitySchemes:
token: token:
type: http type: http
scheme: bearer scheme: bearer