Skip to content

Commit

Permalink
Add api-docs do backend
Browse files Browse the repository at this point in the history
  • Loading branch information
rtenorioh committed Mar 16, 2022
1 parent 5404c22 commit d9ee550
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 3 deletions.
4 changes: 3 additions & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"sequelize-cli": "^5.5.1",
"sequelize-typescript": "^1.1.0",
"socket.io": "^3.0.5",
"swagger-ui-express": "^4.3.0",
"uuid": "^8.3.2",
"whatsapp-web.js": "^1.16.4",
"yup": "^0.32.8"
Expand All @@ -56,6 +57,7 @@
"@types/mustache": "^4.1.2",
"@types/node": "^14.11.8",
"@types/supertest": "^2.0.10",
"@types/swagger-ui-express": "^4.1.3",
"@types/uuid": "^8.3.3",
"@types/validator": "^13.1.0",
"@types/yup": "^0.29.8",
Expand All @@ -77,4 +79,4 @@
"ts-node-dev": "^1.0.0-pre.63",
"typescript": "4.0.3"
}
}
}
7 changes: 6 additions & 1 deletion backend/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@ import app from "./app";
import { initIO } from "./libs/socket";
import { logger } from "./utils/logger";
import { StartAllWhatsAppsSessions } from "./services/WbotServices/StartAllWhatsAppsSessions";
import swaggerUi from "swagger-ui-express";

import swaggerDocs from "./swagger.json"

app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(swaggerDocs));

const server = app.listen(process.env.PORT, () => {
logger.info(`Server started on port: ${process.env.PORT}`);
});

initIO(server);
StartAllWhatsAppsSessions();
gracefulShutdown(server);
gracefulShutdown(server);
92 changes: 92 additions & 0 deletions backend/src/swagger.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"openapi": "3.0.0",
"info": {
"title": "Documentação da API do Press Ticket",
"description": "Documentação da API para envio de mensagens e mídia.",
"contact": {
"email": "robson.tenorio@gmail.com"
},
"version": "1.0.0"
},
"servers": [
{
"url": "https://apisac.pypress.com.br",
"description": "API Press Ticket"
}
],
"paths": {
"/api/messages/send": {
"post": {
"summary": "Envio de Mensagens",
"description": "Envio de Mensagens",
"tags": [
"SEND"
],
"security": [
{
"bearerAuth": []
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#components/schemas/SEND"
},
"examples": {
"SEND": {
"value": {
"number": "5522999999999",
"body": "Mensagem de Teste da API"
}
}
}
}
}
},
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"type": "object",
"$ref": "#components/schemas/SEND"
}
}
}
},
"401": {
"description": "Acesso não autorizado!"
},
"500": {
"description": "Erro interno!"
}
}
}
}

},
"components": {
"schemas": {
"SEND": {
"type": "object",
"properties": {
"number": {
"type": "number"
},
"body": {
"type": "string"
}
}
}
},
"securitySchemes": {
"bearerAuth": {
"type": "http",
"scheme": "bearer",
"bearerFormat": "JWT"
}
}
}
}
3 changes: 2 additions & 1 deletion backend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true
}
}

0 comments on commit d9ee550

Please sign in to comment.