From 8603bef573b51ecd2008007ff9629f71cc9da609 Mon Sep 17 00:00:00 2001 From: Suman991 Date: Fri, 17 Apr 2026 10:38:20 +0530 Subject: [PATCH] added swagger docs --- src/conversations/conversations.controller.ts | 47 ++++++++++++++++++- .../dto/create-conversation.dto.ts | 2 +- 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/src/conversations/conversations.controller.ts b/src/conversations/conversations.controller.ts index f0cd808..6784eb4 100644 --- a/src/conversations/conversations.controller.ts +++ b/src/conversations/conversations.controller.ts @@ -10,7 +10,7 @@ import { import { ConversationsService } from './conversations.service'; import { CreateConversationDto } from './dto/create-conversation.dto'; import { UpdateConversationDto } from './dto/update-conversation.dto'; -import { ApiOperation } from '@nestjs/swagger'; +import { ApiBody, ApiOperation, ApiParam, ApiResponse } from '@nestjs/swagger'; import path from 'path'; @Controller('conversations') @@ -30,6 +30,28 @@ export class ConversationsController { } @Patch(':convId/add-participant') + @ApiOperation({ summary: 'Add a participant to a conversation' }) + @ApiParam({ + name: 'convId', + type: String, + description: 'The ID of the conversation', + example: 'conv_abc123', + }) + @ApiBody({ + schema: { + type: 'object', + required: ['userId'], + properties: { + userId: { + type: 'string', + description: 'The ID of the user to add', + example: 'user_xyz789', + }, + }, + }, + }) + @ApiResponse({ status: 200, description: 'Participant added successfully' }) + @ApiResponse({ status: 404, description: 'Conversation or user not found' }) async addParticipant( @Param('convId') convId: string, @Body('userId') userId: string, @@ -38,10 +60,33 @@ export class ConversationsController { } @Patch(':convId/remove-participant') + @ApiOperation({ summary: 'Remove a participant from a conversation' }) + @ApiParam({ + name: 'convId', + type: String, + description: 'The ID of the conversation', + example: 'conv_abc123', + }) + @ApiBody({ + schema: { + type: 'object', + required: ['userId'], + properties: { + userId: { + type: 'string', + description: 'The ID of the user to remove', + example: 'user_xyz789', + }, + }, + }, + }) + @ApiResponse({ status: 200, description: 'Participant removed successfully' }) + @ApiResponse({ status: 404, description: 'Conversation or user not found' }) async removeParticipant( @Param('convId') convId: string, @Body('userId') userId: string, ) { return this.conversationsService.removeParticipant(convId, userId); } + } diff --git a/src/conversations/dto/create-conversation.dto.ts b/src/conversations/dto/create-conversation.dto.ts index bc62195..77e3840 100644 --- a/src/conversations/dto/create-conversation.dto.ts +++ b/src/conversations/dto/create-conversation.dto.ts @@ -14,7 +14,7 @@ export class CreateConversationDto { @ApiProperty({ enum: ConversationType, enumName: 'ConversationType', - example: ConversationType.P2P, + example: ConversationType.GROUP, description: 'Type of the conversation', }) @IsEnum(ConversationType)