11import { 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' ;
33import { User } from '../user/user.decorator' ;
44import { IArticleRO , IArticlesRO , ICommentsRO } from './article.interface' ;
55import { ArticleService } from './article.service' ;
@@ -38,18 +38,20 @@ export class ArticleController {
3838 }
3939
4040 @ApiOperation ( { summary : 'Create article' } )
41+ @ApiBody ( { type : CreateArticleDto } )
4142 @ApiResponse ( { status : 201 , description : 'The article has been successfully created.' } )
4243 @ApiResponse ( { status : 403 , description : 'Forbidden.' } )
4344 @Post ( )
44- async create ( @User ( 'id' ) userId : number , @Body ( 'article' ) articleData : CreateArticleDto ) {
45+ async create ( @User ( 'id' ) userId : number , @Body ( ) articleData : CreateArticleDto ) {
4546 return this . articleService . create ( userId , articleData ) ;
4647 }
4748
4849 @ApiOperation ( { summary : 'Update article' } )
50+ @ApiBody ( { type : CreateArticleDto } )
4951 @ApiResponse ( { status : 201 , description : 'The article has been successfully updated.' } )
5052 @ApiResponse ( { status : 403 , description : 'Forbidden.' } )
5153 @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 ) {
5355 // Todo: update slug also when title gets changed
5456 return this . articleService . update ( + user , params . slug , articleData ) ;
5557 }
@@ -63,10 +65,11 @@ export class ArticleController {
6365 }
6466
6567 @ApiOperation ( { summary : 'Create comment' } )
68+ @ApiBody ( { type : CreateCommentDto } )
6669 @ApiResponse ( { status : 201 , description : 'The comment has been successfully created.' } )
6770 @ApiResponse ( { status : 403 , description : 'Forbidden.' } )
6871 @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 ) {
7073 return this . articleService . addComment ( user , slug , commentData ) ;
7174 }
7275
0 commit comments