43 lines
914 B
JavaScript
43 lines
914 B
JavaScript
import { Router } from 'express';
|
|
import swaggerJsdoc from 'swagger-jsdoc';
|
|
import swaggerUi from 'swagger-ui-express';
|
|
|
|
const router = Router();
|
|
|
|
const options = {
|
|
definition: {
|
|
openapi: '3.0.0',
|
|
info: {
|
|
title: 'CV API',
|
|
version: '1.0.0',
|
|
description: 'API for CV/Resume management',
|
|
},
|
|
servers: [
|
|
{ url: '/api', description: 'API server' }
|
|
],
|
|
components: {
|
|
securitySchemes: {
|
|
bearerAuth: {
|
|
type: 'http',
|
|
scheme: 'bearer',
|
|
},
|
|
},
|
|
},
|
|
},
|
|
apis: ['./routes/*.js'],
|
|
};
|
|
|
|
const specs = swaggerJsdoc(options);
|
|
|
|
router.use('/docs', swaggerUi.serve, swaggerUi.setup(specs, {
|
|
customCss: '.swagger-ui .topbar { display: none }',
|
|
customSiteTitle: 'CV API Documentation'
|
|
}));
|
|
|
|
router.get('/docs.json', (req, res) => {
|
|
res.setHeader('Content-Type', 'application/json');
|
|
res.send(specs);
|
|
});
|
|
|
|
export default router;
|