42 lines
1.0 KiB
JavaScript
42 lines
1.0 KiB
JavaScript
const swaggerJsdoc = require('swagger-jsdoc');
|
|
const swaggerUi = require('swagger-ui-express');
|
|
|
|
const options = {
|
|
definition: {
|
|
openapi: '3.0.0',
|
|
servers: [
|
|
{
|
|
url: 'https://api.2weekmail.test',
|
|
description: 'Test Environment',
|
|
},
|
|
{
|
|
url: 'https://api.2weekmail.fyi',
|
|
description: 'Production Environment',
|
|
},
|
|
],
|
|
info: {
|
|
title: 'Temporary Email API',
|
|
version: '1.0.0',
|
|
description: 'API documentation for the temporary email service',
|
|
},
|
|
components: {
|
|
securitySchemes: {
|
|
bearerAuth: {
|
|
type: 'http',
|
|
scheme: 'bearer',
|
|
bearerFormat: 'JWT',
|
|
},
|
|
},
|
|
},
|
|
},
|
|
apis: ['./controllers/*.js'], // Path to the API docs
|
|
};
|
|
|
|
const specs = swaggerJsdoc(options);
|
|
|
|
module.exports = (app) => {
|
|
console.log('Setting up Swagger UI...');
|
|
console.log('Swagger spec generated successfully');
|
|
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(specs));
|
|
console.log('Swagger UI setup complete');
|
|
}; |