Skip to content

Commit

Permalink
✨ add api docs
Browse files Browse the repository at this point in the history
  • Loading branch information
KMUlee committed Apr 25, 2024
1 parent 275820c commit e5c4cca
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/profile/dto/profile.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,14 @@ export class ProfileDto {

export class GetProfileDto extends ProfileDto {
@Type(() => ProfileDto)
@ApiProperty()
@ApiProperty({
type: [ProfileDto],
})
likedByUsers: ProfileDto[] | [];

@Type(() => ProfileDto)
@ApiProperty()
@ApiProperty({
type: [ProfileDto],
})
likedProjects: ProfileDto[] | [];
}
40 changes: 39 additions & 1 deletion src/profile/profile.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { ProfileService } from './profile.service';
import { JwtAuthGuard } from 'src/user/user.guard';
import { GetUser } from 'src/user/decorators/GetUser.decorator';
import { Payload } from 'src/user/dto/jwt-payload.dto';
import { ApiBearerAuth } from '@nestjs/swagger';
import { ApiBearerAuth, ApiBody, ApiParam, ApiResponse } from '@nestjs/swagger';
import { GetProfileDto, ProfileDto } from './dto/profile.dto';

@Controller('profile')
Expand All @@ -22,6 +22,16 @@ export class ProfileController {
constructor(private readonly profileService: ProfileService) {}

@Get('/:id')
@ApiParam({
name: 'id',
description: 'userId',
type: 'number',
})
@ApiResponse({
status: 200,
description: 'Get a profile',
type: GetProfileDto,
})
async getProfile(
@Param('id') id: number,
@GetUser() user: Payload,
Expand All @@ -35,6 +45,20 @@ export class ProfileController {
}

@Post('/:id')
@ApiParam({
name: 'id',
description: 'userId',
type: 'number',
})
@ApiBody({
description: 'Create a profile',
type: ProfileDto,
})
@ApiResponse({
status: 200,
description: 'Get a profile',
type: ProfileDto,
})
async createProfile(
@Param('id') id: number,
@GetUser() user: Payload,
Expand All @@ -49,6 +73,20 @@ export class ProfileController {
}

@Put('/:id')
@ApiParam({
name: 'id',
description: 'userId',
type: 'number',
})
@ApiBody({
description: 'Create a profile',
type: ProfileDto,
})
@ApiResponse({
status: 200,
description: 'Get a profile',
type: ProfileDto,
})
async updateProfile(
@Param('id') id: number,
@GetUser() user: Payload,
Expand Down

0 comments on commit e5c4cca

Please sign in to comment.