Skip to content

Commit

Permalink
Merge pull request #147 from boostcampwm-2024/feature/be/#42-loginapi
Browse files Browse the repository at this point in the history
[BE][Feat] : #42 : 로그인 api swagger 문서 작성
  • Loading branch information
happyhyep authored Nov 12, 2024
2 parents 4f606e5 + 6070190 commit ecd0e82
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 2 deletions.
24 changes: 24 additions & 0 deletions backend/src/routes/authRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
[
Expand Down
35 changes: 33 additions & 2 deletions backend/swaggerConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down

0 comments on commit ecd0e82

Please sign in to comment.