-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Set up Swagger documentation structure
-Initialize Swagger JSDoc and Swagger UI integration -Create basic folder structure for API documentation -Add swagger.js configuration file -Set up initial swagger.js file -Prepare controllers for Swagger annotations -Add necessary dependencies for Swagger integration
- Loading branch information
1 parent
34bf4f8
commit e101f10
Showing
5 changed files
with
329 additions
and
2 deletions.
There are no files selected for viewing
Empty file.
Empty file.
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,53 @@ | ||
const swaggerJSDoc = require('swagger-jsdoc'); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const yaml = require('js-yaml'); | ||
|
||
const options = { | ||
definition: { | ||
openapi: '3.0.0', | ||
info: { | ||
title: 'LogArt API', | ||
version: '1.0.0', | ||
description: 'Documentación API REST para la aplicación LogArt', | ||
contact: { | ||
name: 'David Moreno Martín', | ||
email: '[email protected]', | ||
url: 'https://github.com/codeurjc-students/2024-logart', | ||
}, | ||
}, | ||
servers: [ | ||
{ | ||
url: 'https://localhost:443/api/v1', | ||
description: 'Servidor de desarrollo', | ||
}, | ||
], | ||
components: { | ||
securitySchemes: { | ||
BearerAuth: { | ||
type: 'http', | ||
scheme: 'bearer', | ||
bearerFormat: 'JWT', | ||
}, | ||
}, | ||
schemas: { | ||
}, | ||
}, | ||
security: [ | ||
{ | ||
BearerAuth: [], | ||
}, | ||
], | ||
}, | ||
apis: [path.join(__dirname, '../controllers/*.js')], | ||
}; | ||
|
||
const swaggerSpec = swaggerJSDoc(options); | ||
|
||
const swaggerYaml = yaml.dump(swaggerSpec); | ||
|
||
fs.writeFileSync(path.join(__dirname, 'api-docs.yaml'), swaggerYaml, 'utf8'); | ||
|
||
console.log('Archivo api-docs.yaml generado exitosamente.'); | ||
|
||
module.exports = swaggerSpec; |
Oops, something went wrong.