update swagger docs

This commit is contained in:
Le Viet
2022-03-14 20:14:18 +07:00
parent f5c8f25209
commit 870e5b089e
9 changed files with 692 additions and 6512 deletions
+216 -2
View File
@@ -2,12 +2,226 @@ const memberController = require("../controllers").member;
const auth = require("../middleware/auth");
module.exports = app => {
/**
* @swagger
* /v1/user/register:
* post:
* tags:
* - Users
* summary: Create a JSONPlaceholder user.
* requestBody:
* required: true
* content:
* application/json:
* schema:
* type: object
* properties:
* username:
* type: string
* description: The user's username.
* example: test@float.sg
* email:
* type: string
* description: The user's email.
* example: test@float.sg
* password:
* type: string
* description: The user's password.
* example: test@float.sg
* firstname:
* type: string
* description: The user's firstname.
* example: Float
* lastname:
* type: string
* description: The user's lastname.
* example: Mobility
* phone:
* type: string
* description: The user's phone.
* example: 123456789
* responses:
* 200:
* description: Created
* content:
* application/json:
* schema:
* type: object
* properties:
* message:
* type: striing
* description: Message
* example: Register successfully
* 400:
* description: Invalid
* content:
* application/json:
* schema:
* type: object
* properties:
* message:
* type: striing
* description: Message
* example: Failed
*/
app.post("/api/v1/user/register", memberController.validate('register'), memberController.register);
/**
* @swagger
* /v1/user/login:
* post:
* tags:
* - Users
* summary: Create a JSONPlaceholder user.
* requestBody:
* required: true
* content:
* application/json:
* schema:
* type: object
* properties:
* username:
* type: string
* description: The user's username.
* example: test@float.sg
* password:
* type: string
* description: The user's password.
* example: test@float.sg
* responses:
* 200:
* description: Login success
* content:
* application/json:
* schema:
* type: object
* properties:
* accessToken:
* type: string
* description: Message
* example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RAZmxvYXQuc2ciLCJpYXQiOjE2NDcwODIxNDIsImV4cCI6MTY0NzA4Mzk0Mn0.fMQYB4ielKPh21QcZFwOJSjlGNCAg8rkvEcKWctxdX8
* 400:
* description: Invalid
* content:
* application/json:
* schema:
* type: object
* properties:
* message:
* type: string
* description: Message
* example: Wrong username or password
*/
app.post("/api/v1/user/login", memberController.login);
/**
* @swagger
* /v1/user/forgot-password:
* post:
* tags:
* - Users
* summary: Create a JSONPlaceholder user.
* requestBody:
* required: true
* content:
* application/json:
* schema:
* type: object
* properties:
* email:
* type: string
* description: The user's username.
* example: test@float.sg
* responses:
* 200:
* description: Login success
* content:
* application/json:
* schema:
* type: object
* properties:
* message:
* type: string
* description: Message
* example: Email has been sent
* 400:
* description: Invalid
* content:
* application/json:
* schema:
* type: object
* properties:
* message:
* type: string
* description: Message
* example: Wrong email
*/
app.post("/api/v1/user/forgot-password", memberController.forgotPassword);
/**
* @swagger
* /v1/user/reset-password:
* post:
* tags:
* - Users
* summary: Create a JSONPlaceholder user.
* requestBody:
* required: true
* content:
* application/json:
* schema:
* type: object
* properties:
* email:
* type: string
* description: The user's username.
* example: test@float.sg
* mode:
* type: integer
* description: The reset mode (100: start, 200:confirm, 300:complete)
* example: 100
* responses:
* 200:
* description: Login success
* content:
* application/json:
* schema:
* type: object
* properties:
* accessToken:
* type: string
* description: Message
* example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RAZmxvYXQuc2ciLCJpYXQiOjE2NDcwODIxNDIsImV4cCI6MTY0NzA4Mzk0Mn0.fMQYB4ielKPh21QcZFwOJSjlGNCAg8rkvEcKWctxdX8
* 400:
* description: Invalid
* content:
* application/json:
* schema:
* type: object
* properties:
* message:
* type: string
* description: Message
* example: Wrong username or password
*/
app.post("/api/v1/user/reset-password", memberController.resetPassword);
app.post("/api/v1/user/confirm-reset-password", memberController.confirmResetPassword);
app.post("/api/v1/user/complete-reset-password", memberController.completeResetPassword);
/**
* @swagger
* /v1/user/profile:
* get:
* tags:
* - Users
* summary: Retrieve a single JSONPlaceholder user.
* description: Retrieve a single JSONPlaceholder user. Can be used to populate a user profile when prototyping or testing an API.
* security: # <--- ADD THIS
* - bearerAuth: [] # <--- ADD THIS
* responses:
* 200:
* description: A single user.
* content:
* application/json:
* schema:
* type: object
* $ref: '#/components/schemas/Member'
*/
app.get("/api/v1/user/profile", auth, memberController.profile);
};