Skip to content

Commit eaade5f

Browse files
committed
chore: migrate swagger
1 parent 5c019f6 commit eaade5f

File tree

4 files changed

+17
-22
lines changed

4 files changed

+17
-22
lines changed

src/article/article.controller.ts

+11-12
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,27 @@ import { CommentsRO } from './article.interface';
77
import { User } from '../user/user.decorator';
88

99
import {
10-
ApiUseTags,
1110
ApiBearerAuth,
1211
ApiResponse,
13-
ApiOperation,
12+
ApiOperation, ApiTags,
1413
} from '@nestjs/swagger';
1514

1615
@ApiBearerAuth()
17-
@ApiUseTags('articles')
16+
@ApiTags('articles')
1817
@Controller('articles')
1918
export class ArticleController {
2019

2120
constructor(private readonly articleService: ArticleService) {}
2221

23-
@ApiOperation({ title: 'Get all articles' })
22+
@ApiOperation({ summary: 'Get all articles' })
2423
@ApiResponse({ status: 200, description: 'Return all articles.'})
2524
@Get()
2625
async findAll(@Query() query): Promise<ArticlesRO> {
2726
return await this.articleService.findAll(query);
2827
}
2928

3029

31-
@ApiOperation({ title: 'Get article feed' })
30+
@ApiOperation({ summary: 'Get article feed' })
3231
@ApiResponse({ status: 200, description: 'Return article feed.'})
3332
@ApiResponse({ status: 403, description: 'Forbidden.' })
3433
@Get('feed')
@@ -46,15 +45,15 @@ export class ArticleController {
4645
return await this.articleService.findComments(slug);
4746
}
4847

49-
@ApiOperation({ title: 'Create article' })
48+
@ApiOperation({ summary: 'Create article' })
5049
@ApiResponse({ status: 201, description: 'The article has been successfully created.'})
5150
@ApiResponse({ status: 403, description: 'Forbidden.' })
5251
@Post()
5352
async create(@User('id') userId: number, @Body('article') articleData: CreateArticleDto) {
5453
return this.articleService.create(userId, articleData);
5554
}
5655

57-
@ApiOperation({ title: 'Update article' })
56+
@ApiOperation({ summary: 'Update article' })
5857
@ApiResponse({ status: 201, description: 'The article has been successfully updated.'})
5958
@ApiResponse({ status: 403, description: 'Forbidden.' })
6059
@Put(':slug')
@@ -63,23 +62,23 @@ export class ArticleController {
6362
return this.articleService.update(params.slug, articleData);
6463
}
6564

66-
@ApiOperation({ title: 'Delete article' })
65+
@ApiOperation({ summary: 'Delete article' })
6766
@ApiResponse({ status: 201, description: 'The article has been successfully deleted.'})
6867
@ApiResponse({ status: 403, description: 'Forbidden.' })
6968
@Delete(':slug')
7069
async delete(@Param() params) {
7170
return this.articleService.delete(params.slug);
7271
}
7372

74-
@ApiOperation({ title: 'Create comment' })
73+
@ApiOperation({ summary: 'Create comment' })
7574
@ApiResponse({ status: 201, description: 'The comment has been successfully created.'})
7675
@ApiResponse({ status: 403, description: 'Forbidden.' })
7776
@Post(':slug/comments')
7877
async createComment(@Param('slug') slug, @Body('comment') commentData: CreateCommentDto) {
7978
return await this.articleService.addComment(slug, commentData);
8079
}
8180

82-
@ApiOperation({ title: 'Delete comment' })
81+
@ApiOperation({ summary: 'Delete comment' })
8382
@ApiResponse({ status: 201, description: 'The article has been successfully deleted.'})
8483
@ApiResponse({ status: 403, description: 'Forbidden.' })
8584
@Delete(':slug/comments/:id')
@@ -88,15 +87,15 @@ export class ArticleController {
8887
return await this.articleService.deleteComment(slug, id);
8988
}
9089

91-
@ApiOperation({ title: 'Favorite article' })
90+
@ApiOperation({ summary: 'Favorite article' })
9291
@ApiResponse({ status: 201, description: 'The article has been successfully favorited.'})
9392
@ApiResponse({ status: 403, description: 'Forbidden.' })
9493
@Post(':slug/favorite')
9594
async favorite(@User('id') userId: number, @Param('slug') slug) {
9695
return await this.articleService.favorite(userId, slug);
9796
}
9897

99-
@ApiOperation({ title: 'Unfavorite article' })
98+
@ApiOperation({ summary: 'Unfavorite article' })
10099
@ApiResponse({ status: 201, description: 'The article has been successfully unfavorited.'})
101100
@ApiResponse({ status: 403, description: 'Forbidden.' })
102101
@Delete(':slug/favorite')

src/profile/profile.controller.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@ import { ProfileRO } from './profile.interface';
55
import { User } from '../user/user.decorator';
66

77
import {
8-
ApiUseTags,
9-
ApiBearerAuth,
8+
ApiBearerAuth, ApiTags,
109
} from '@nestjs/swagger';
1110

1211
@ApiBearerAuth()
13-
@ApiUseTags('profiles')
12+
@ApiTags('profiles')
1413
@Controller('profiles')
1514
export class ProfileController {
1615

src/tag/tag.controller.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@ import { TagEntity } from './tag.entity';
44
import { TagService } from './tag.service';
55

66
import {
7-
ApiUseTags,
8-
ApiBearerAuth,
7+
ApiBearerAuth, ApiTags,
98
} from '@nestjs/swagger';
109

1110
@ApiBearerAuth()
12-
@ApiUseTags('tags')
11+
@ApiTags('tags')
1312
@Controller('tags')
1413
export class TagController {
1514

src/user/user.controller.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
import { Get, Post, Body, Put, Delete, Param, Controller, UsePipes } from '@nestjs/common';
22
import { Request } from 'express';
33
import { UserService } from './user.service';
4-
import { UserEntity } from './user.entity';
54
import { UserRO } from './user.interface';
65
import { CreateUserDto, UpdateUserDto, LoginUserDto } from './dto';
76
import { HttpException } from '@nestjs/common/exceptions/http.exception';
87
import { User } from './user.decorator';
98
import { ValidationPipe } from '../shared/pipes/validation.pipe';
109

1110
import {
12-
ApiUseTags,
13-
ApiBearerAuth
11+
ApiBearerAuth, ApiTags
1412
} from '@nestjs/swagger';
1513

1614
@ApiBearerAuth()
17-
@ApiUseTags('user')
15+
@ApiTags('user')
1816
@Controller()
1917
export class UserController {
2018

0 commit comments

Comments
 (0)