diff --git a/backend/src/routes/authRouter.js b/backend/src/routes/authRouter.js index caf0b954..65d8dfcf 100644 --- a/backend/src/routes/authRouter.js +++ b/backend/src/routes/authRouter.js @@ -5,6 +5,30 @@ import { validationMiddleware } from '../middleware/validationMiddleware.js'; export const authRouter = express.Router(); +/** + * @swagger + * /api/auth/login: + * post: + * summary: User login + * description: Logs in a user with their ID and password. + * requestBody: + * required: true + * content: + * application/json: + * schema: + * $ref: '#/components/schemas/LoginRequest' + * responses: + * 200: + * description: Successfully logged in + * content: + * application/json: + * schema: + * $ref: '#/components/schemas/LoginResponse' + * 400: + * description: Invalid input (e.g. invalid ID or password) + * 500: + * description: Internal server error + */ authRouter.post( '/login', [ diff --git a/backend/swaggerConfig.js b/backend/swaggerConfig.js index 09ae4746..44349895 100644 --- a/backend/swaggerConfig.js +++ b/backend/swaggerConfig.js @@ -3,15 +3,46 @@ import swaggerJSDoc from 'swagger-jsdoc'; const swaggerDefinition = { openapi: '3.0.0', info: { - title: 'Your API Name', + title: 'DDara API', version: '1.0.0', - description: 'API documentation for Your Project', + description: 'API documentation for DDara Project', }, servers: [ { url: 'http://localhost:3001', }, ], + components: { + schemas: { + LoginRequest: { + type: 'object', + properties: { + id: { + type: 'string', + description: 'User ID', + }, + password: { + type: 'string', + description: 'User password', + }, + }, + }, + LoginResponse: { + type: 'object', + properties: { + token: { + type: 'string', + description: 'Authentication token', + }, + userId: { + type: 'string', + description: 'User ID', + }, + }, + }, + }, + }, + paths: {}, }; const options = {