-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(swagger): add swagger settings to the project
Refs #94
- Loading branch information
1 parent
6817eae
commit 32b492c
Showing
2 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { Express } from "express"; | ||
import swaggerJSDoc from "swagger-jsdoc"; | ||
import swaggerUi from "swagger-ui-express"; | ||
|
||
const options = { | ||
definition: { | ||
openapi: "3.0.0", | ||
info: { | ||
title: "API Documentation", | ||
version: "1.0.0", | ||
description: "API documentation for the project", | ||
}, | ||
servers: [ | ||
{ | ||
url: "http://localhost:8000", | ||
}, | ||
{ | ||
url: "https://your-app-name.onrender.com", | ||
}, | ||
], | ||
components: { | ||
securitySchemes: { | ||
bearerAuth: { | ||
type: "http", | ||
scheme: "bearer", | ||
bearerFormat: "JWT", | ||
}, | ||
}, | ||
}, | ||
security: [ | ||
{ | ||
bearerAuth: [], | ||
}, | ||
], | ||
}, | ||
apis: ["./src/**/*.ts"], // Caminho para os arquivos que contêm as anotações JSDoc | ||
}; | ||
|
||
const swaggerSpec = swaggerJSDoc(options); | ||
|
||
export const setupSwagger = (app: Express): void => { | ||
app.use("/docs", swaggerUi.serve, swaggerUi.setup(swaggerSpec)); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters