added swagger docs

This commit is contained in:
Suman991 2026-04-17 10:38:20 +05:30
parent 820fc9934c
commit 8603bef573
2 changed files with 47 additions and 2 deletions

View File

@ -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);
}
}

View File

@ -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)