const swaggerJsdoc = require('swagger-jsdoc'); const path = require('path'); const options = { definition: { openapi: '3.0.0', info: { title: 'Products API', version: '1.0.0', description: 'API documentation for Products management with SQLite', }, servers: [ { url: 'http://localhost:3000', description: 'Development server', }, ], components: { schemas: { Product: { type: 'object', required: ['name', 'description', 'price'], properties: { id: { type: 'integer', description: 'Auto-generated product ID', }, name: { type: 'string', description: 'Product name', }, description: { type: 'string', description: 'Product description', }, price: { type: 'number', description: 'Product price', }, }, }, ProductResponse: { type: 'object', properties: { status: { type: 'string', example: 'success', }, new_product: { $ref: '#/components/schemas/Product', }, }, }, UpdateResponse: { type: 'object', properties: { message: { type: 'string', example: 'Mise a jour avec succes', }, data: { $ref: '#/components/schemas/Product', }, }, }, Error: { type: 'object', properties: { error: { type: 'string', description: 'Error message', }, }, }, }, }, }, apis: [path.join(__dirname, './routes/*.js')], }; const swaggerSpec = swaggerJsdoc(options); module.exports = swaggerSpec;