1
1
import { Body , Controller , Delete , Get , Param , Post , Put , Query } from '@nestjs/common' ;
2
- import { ApiBearerAuth , ApiOperation , ApiResponse , ApiTags } from '@nestjs/swagger' ;
2
+ import { ApiBearerAuth , ApiBody , ApiOperation , ApiResponse , ApiTags } from '@nestjs/swagger' ;
3
3
import { User } from '../user/user.decorator' ;
4
4
import { IArticleRO , IArticlesRO , ICommentsRO } from './article.interface' ;
5
5
import { ArticleService } from './article.service' ;
@@ -38,18 +38,20 @@ export class ArticleController {
38
38
}
39
39
40
40
@ApiOperation ( { summary : 'Create article' } )
41
+ @ApiBody ( { type : CreateArticleDto } )
41
42
@ApiResponse ( { status : 201 , description : 'The article has been successfully created.' } )
42
43
@ApiResponse ( { status : 403 , description : 'Forbidden.' } )
43
44
@Post ( )
44
- async create ( @User ( 'id' ) userId : number , @Body ( 'article' ) articleData : CreateArticleDto ) {
45
+ async create ( @User ( 'id' ) userId : number , @Body ( ) articleData : CreateArticleDto ) {
45
46
return this . articleService . create ( userId , articleData ) ;
46
47
}
47
48
48
49
@ApiOperation ( { summary : 'Update article' } )
50
+ @ApiBody ( { type : CreateArticleDto } )
49
51
@ApiResponse ( { status : 201 , description : 'The article has been successfully updated.' } )
50
52
@ApiResponse ( { status : 403 , description : 'Forbidden.' } )
51
53
@Put ( ':slug' )
52
- async update ( @User ( 'id' ) user : number , @Param ( ) params , @Body ( 'article' ) articleData : CreateArticleDto ) {
54
+ async update ( @User ( 'id' ) user : number , @Param ( ) params , @Body ( ) articleData : CreateArticleDto ) {
53
55
// Todo: update slug also when title gets changed
54
56
return this . articleService . update ( + user , params . slug , articleData ) ;
55
57
}
@@ -63,10 +65,11 @@ export class ArticleController {
63
65
}
64
66
65
67
@ApiOperation ( { summary : 'Create comment' } )
68
+ @ApiBody ( { type : CreateCommentDto } )
66
69
@ApiResponse ( { status : 201 , description : 'The comment has been successfully created.' } )
67
70
@ApiResponse ( { status : 403 , description : 'Forbidden.' } )
68
71
@Post ( ':slug/comments' )
69
- async createComment ( @User ( 'id' ) user : number , @Param ( 'slug' ) slug , @Body ( 'comment' ) commentData : CreateCommentDto ) {
72
+ async createComment ( @User ( 'id' ) user : number , @Param ( 'slug' ) slug , @Body ( ) commentData : CreateCommentDto ) {
70
73
return this . articleService . addComment ( user , slug , commentData ) ;
71
74
}
72
75
0 commit comments