@@ -7,28 +7,27 @@ import { CommentsRO } from './article.interface';
7
7
import { User } from '../user/user.decorator' ;
8
8
9
9
import {
10
- ApiUseTags ,
11
10
ApiBearerAuth ,
12
11
ApiResponse ,
13
- ApiOperation ,
12
+ ApiOperation , ApiTags ,
14
13
} from '@nestjs/swagger' ;
15
14
16
15
@ApiBearerAuth ( )
17
- @ApiUseTags ( 'articles' )
16
+ @ApiTags ( 'articles' )
18
17
@Controller ( 'articles' )
19
18
export class ArticleController {
20
19
21
20
constructor ( private readonly articleService : ArticleService ) { }
22
21
23
- @ApiOperation ( { title : 'Get all articles' } )
22
+ @ApiOperation ( { summary : 'Get all articles' } )
24
23
@ApiResponse ( { status : 200 , description : 'Return all articles.' } )
25
24
@Get ( )
26
25
async findAll ( @Query ( ) query ) : Promise < ArticlesRO > {
27
26
return await this . articleService . findAll ( query ) ;
28
27
}
29
28
30
29
31
- @ApiOperation ( { title : 'Get article feed' } )
30
+ @ApiOperation ( { summary : 'Get article feed' } )
32
31
@ApiResponse ( { status : 200 , description : 'Return article feed.' } )
33
32
@ApiResponse ( { status : 403 , description : 'Forbidden.' } )
34
33
@Get ( 'feed' )
@@ -46,15 +45,15 @@ export class ArticleController {
46
45
return await this . articleService . findComments ( slug ) ;
47
46
}
48
47
49
- @ApiOperation ( { title : 'Create article' } )
48
+ @ApiOperation ( { summary : 'Create article' } )
50
49
@ApiResponse ( { status : 201 , description : 'The article has been successfully created.' } )
51
50
@ApiResponse ( { status : 403 , description : 'Forbidden.' } )
52
51
@Post ( )
53
52
async create ( @User ( 'id' ) userId : number , @Body ( 'article' ) articleData : CreateArticleDto ) {
54
53
return this . articleService . create ( userId , articleData ) ;
55
54
}
56
55
57
- @ApiOperation ( { title : 'Update article' } )
56
+ @ApiOperation ( { summary : 'Update article' } )
58
57
@ApiResponse ( { status : 201 , description : 'The article has been successfully updated.' } )
59
58
@ApiResponse ( { status : 403 , description : 'Forbidden.' } )
60
59
@Put ( ':slug' )
@@ -63,23 +62,23 @@ export class ArticleController {
63
62
return this . articleService . update ( params . slug , articleData ) ;
64
63
}
65
64
66
- @ApiOperation ( { title : 'Delete article' } )
65
+ @ApiOperation ( { summary : 'Delete article' } )
67
66
@ApiResponse ( { status : 201 , description : 'The article has been successfully deleted.' } )
68
67
@ApiResponse ( { status : 403 , description : 'Forbidden.' } )
69
68
@Delete ( ':slug' )
70
69
async delete ( @Param ( ) params ) {
71
70
return this . articleService . delete ( params . slug ) ;
72
71
}
73
72
74
- @ApiOperation ( { title : 'Create comment' } )
73
+ @ApiOperation ( { summary : 'Create comment' } )
75
74
@ApiResponse ( { status : 201 , description : 'The comment has been successfully created.' } )
76
75
@ApiResponse ( { status : 403 , description : 'Forbidden.' } )
77
76
@Post ( ':slug/comments' )
78
77
async createComment ( @Param ( 'slug' ) slug , @Body ( 'comment' ) commentData : CreateCommentDto ) {
79
78
return await this . articleService . addComment ( slug , commentData ) ;
80
79
}
81
80
82
- @ApiOperation ( { title : 'Delete comment' } )
81
+ @ApiOperation ( { summary : 'Delete comment' } )
83
82
@ApiResponse ( { status : 201 , description : 'The article has been successfully deleted.' } )
84
83
@ApiResponse ( { status : 403 , description : 'Forbidden.' } )
85
84
@Delete ( ':slug/comments/:id' )
@@ -88,15 +87,15 @@ export class ArticleController {
88
87
return await this . articleService . deleteComment ( slug , id ) ;
89
88
}
90
89
91
- @ApiOperation ( { title : 'Favorite article' } )
90
+ @ApiOperation ( { summary : 'Favorite article' } )
92
91
@ApiResponse ( { status : 201 , description : 'The article has been successfully favorited.' } )
93
92
@ApiResponse ( { status : 403 , description : 'Forbidden.' } )
94
93
@Post ( ':slug/favorite' )
95
94
async favorite ( @User ( 'id' ) userId : number , @Param ( 'slug' ) slug ) {
96
95
return await this . articleService . favorite ( userId , slug ) ;
97
96
}
98
97
99
- @ApiOperation ( { title : 'Unfavorite article' } )
98
+ @ApiOperation ( { summary : 'Unfavorite article' } )
100
99
@ApiResponse ( { status : 201 , description : 'The article has been successfully unfavorited.' } )
101
100
@ApiResponse ( { status : 403 , description : 'Forbidden.' } )
102
101
@Delete ( ':slug/favorite' )
0 commit comments