swagger: add endpoint to get comments submitted by a user.

master
ALI Hamza 2020-09-09 22:58:10 +07:00
parent 8302b02b90
commit 818d24e29d
Signed by: hamza
GPG Key ID: 22473A32291F8CB6
1 changed files with 101 additions and 14 deletions

@ -107,7 +107,33 @@ paths:
content: content:
application/json: application/json:
schema: schema:
$ref: '#/components/schemas/Post' type: array
items:
$ref: '#/components/schemas/Post'
400:
$ref: '#/components/responses/MalformedBody'
422:
$ref: '#/components/responses/Unprocessable'
500:
$ref: '#/components/responses/ServerError'
/users/{username}/comments:
get:
tags:
- User Endpoints
- Comments Endpoints
summary: Get the list of comments a user has submitted.
requestBody:
$ref: '#/components/requestBodies/Listing'
responses:
200:
description: A list of comments filtered and formatted.
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Comment'
400: 400:
$ref: '#/components/responses/MalformedBody' $ref: '#/components/responses/MalformedBody'
422: 422:
@ -129,11 +155,11 @@ components:
type: object type: object
properties: properties:
username: username:
type: string
description: The username of the user. description: The username of the user.
password:
type: string type: string
password:
description: The password of the user. description: The password of the user.
type: string
TokenRequest: TokenRequest:
description: The access token to identify a user. description: The access token to identify a user.
content: content:
@ -143,8 +169,8 @@ components:
- token - token
properties: properties:
token: token:
type: string
description: The access token. description: The access token.
type: string
Listing: Listing:
description: Query particular data sorted by date and time. description: Query particular data sorted by date and time.
content: content:
@ -206,15 +232,15 @@ components:
- password - password
properties: properties:
username: username:
description: A Unique uusername 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}"
description: A Unique uusername to identify a user around the website.
email: email:
description: A Unique email used for communication/further identification.
type: string type: string
format: email format: email
description: A Unique email used for communication/further identification.
password: password:
type: string type: string
format: password format: password
@ -233,17 +259,76 @@ components:
type: object type: object
properties: properties:
token: token:
description: The access token value.
type: string type: string
description: The access token value
Post: Post:
type: object type: object
required: required:
- id - id
- user_id - user_id
- title - title
- description
- upvotes - upvotes
- downvotes - downvotes
- date_created
properties:
id:
description: The unique ID of a post.
type: string
user_id:
description: The ID of the user who created the post.
type: string
title:
description: The main title of a post.
type: string
description:
description: The body text of a post, optional.
type: string
upvotes:
description: The number of upvotes a post has.
type: integer
downvotes:
description: The number of downvotes a post has.
type: integer
date_created:
description: The time at which this post was submitted.
type: string
format: 'date-time'
Comment:
type: object
required:
- id
- user_id
- post_id
- content
- upvotes
- downvotes
- date_created
properties:
id:
description: The unique ID of a comment.
type: string
user_id:
description: The ID of the user who posted the comment.
type: string
post_id:
description: The ID of the post this comment is created under.
type: string
parent_id:
description: The ID of the parent comment this comment is created to, if not provided, a top-level comment.
type: string
content:
description: The content/message of a comment.
type: string
upvotes:
description: The number of upvotes a comment has.
type: integer
downvotes:
description: The number of downvotes a comment has.
type: integer
date_created:
description: The time at which this comment was submitted.
type: string
format: 'date-time'
Error: Error:
required: required:
- reason - reason
@ -251,32 +336,34 @@ components:
type: object type: object
properties: properties:
reason: reason:
type: string
description: The cause of the error message description: The cause of the error message
type: string
code: code:
type: integer
description: The HTTP error code value accompanying the error. description: The HTTP error code value accompanying the error.
type: integer
Listing: Listing:
type: object type: object
properties: properties:
after: after:
description: Filter items to only return those after this date and time.
type: string type: string
format: 'date-time' format: 'date-time'
description: Filter items to only return those after this date and time.
default: 2020-01-01T00:00:00.000z default: 2020-01-01T00:00:00.000z
before: before:
description: Filter items to only return those before this date and time.
type: string type: string
format: 'date-time' format: 'date-time'
description: Filter items to only return those before this date and time.
default: 2030-01-01T00:00:00.000z default: 2030-01-01T00:00:00.000z
count: count:
type: integer
description: The number of items already seen in this listing. Items will always be sorted by newest first. description: The number of items already seen in this listing. Items will always be sorted by newest first.
type: integer
minimum: 0
default: 0 default: 0
limit: limit:
description: The maximum number of items to provide. Can be used in conjunction with 'count' to paginate.
type: integer type: integer
maximum: 100 maximum: 100
description: The maximum number of items to provide. Can be used in conjunction with 'count' to paginate. minimum: 0
default: 10 default: 10
example: example:
after: 2020-01-01T00:00:00.000z after: 2020-01-01T00:00:00.000z