This commit is contained in:
2024-11-26 13:19:48 +07:00
commit df875117b0
31 changed files with 1273 additions and 0 deletions

17
src/swagger/builder.js Normal file
View File

@ -0,0 +1,17 @@
const swaggerAutogen = require('swagger-autogen')();
const config = require('config');
const doc = {
info: {
title: config.get('app.name'),
description: config.get('app.description'),
version: config.get('app.version')
},
host: config.get('server.host_swagger') + ':' + config.get('server.port'),
};
const outputFile = './swagger.json';
const routes = ['../routes/private.ts', '../routes/public.ts'];
swaggerAutogen(outputFile, routes, doc);

213
src/swagger/swagger.json Normal file
View File

@ -0,0 +1,213 @@
{
"swagger": "2.0",
"info": {
"title": "Service Name",
"description": "Description of service",
"version": "1.0.0"
},
"host": "127.0.0.1:4001",
"basePath": "/",
"schemes": [
"http"
],
"paths": {
"/api/user/list": {
"get": {
"description": "",
"parameters": [
{
"name": "filter",
"in": "query",
"type": "string"
},
{
"name": "limit",
"in": "query",
"required": true,
"type": "number"
},
{
"name": "page",
"in": "query",
"required": true,
"type": "number"
},
{
"name": "with_deleted",
"in": "query",
"required": true,
"type": "boolean"
},
{
"name": "order_field",
"in": "query",
"required": true,
"type": "string"
},
{
"name": "order_direction",
"in": "query",
"required": true,
"enum": [
"ASC",
"DESC"
],
"type": "string"
}
],
"responses": {
"default": {
"description": ""
}
}
}
},
"/api/user/create": {
"post": {
"description": "",
"parameters": [
{
"name": "body",
"in": "body",
"description": "User data",
"required": true,
"schema": {
"type": "object",
"properties": {
"email": {
"type": "string",
"example": "admin@gmail.com"
},
"username": {
"type": "string",
"example": "admin"
},
"password": {
"type": "string",
"example": "123456"
},
"retype_password": {
"type": "string",
"example": "123456"
},
"name": {
"type": "string",
"example": "Administrator"
},
"role": {
"type": "string",
"example": "ADMINISTRATOR"
},
"status": {
"type": "string",
"example": "Y"
}
}
}
}
],
"responses": {
"default": {
"description": ""
}
}
}
},
"/api/user/update/{id}": {
"put": {
"description": "",
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"type": "uuid",
"description": "User ID."
},
{
"name": "body",
"in": "body",
"description": "User data",
"required": true,
"schema": {
"type": "object",
"properties": {
"email": {
"type": "string",
"example": "admin@gmail.com"
},
"username": {
"type": "string",
"example": "admin"
},
"password": {
"type": "string",
"example": "123456"
},
"retype_password": {
"type": "string",
"example": "123456"
},
"name": {
"type": "string",
"example": "Administrator"
},
"role": {
"type": "string",
"example": "ADMINISTRATOR"
},
"status": {
"type": "string",
"example": "Y"
}
}
}
}
],
"responses": {
"default": {
"description": ""
}
}
}
},
"/api/user/delete/{id}": {
"delete": {
"description": "",
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"type": "uuid",
"description": "User ID."
}
],
"responses": {
"default": {
"description": ""
}
}
}
},
"/api/user/restore/{id}": {
"put": {
"description": "",
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"type": "uuid",
"description": "User ID."
}
],
"responses": {
"default": {
"description": ""
}
}
}
}
}
}