From 5e999cb7ffcfd4b2ba0c95ed3ac87d5ae961f8c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Kratochv=C3=ADl?= <xkrato10@fi.muni.cz> Date: Sat, 18 Jun 2022 21:27:14 +0200 Subject: [PATCH] fix: category API endpoints response Swagger docs will be generated with the Nest CLI --- .../src/api/categories/categories.controller.ts | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/backend/src/api/categories/categories.controller.ts b/backend/src/api/categories/categories.controller.ts index c59f95a..560c0c1 100644 --- a/backend/src/api/categories/categories.controller.ts +++ b/backend/src/api/categories/categories.controller.ts @@ -7,7 +7,7 @@ import { Param, Delete, } from '@nestjs/common'; -import { ApiCreatedResponse, ApiOkResponse, ApiTags } from '@nestjs/swagger'; +import { ApiTags } from '@nestjs/swagger'; import { CategoriesService } from './categories.service'; import { CreateCategoryDto } from './dto/create-category.dto'; import { UpdateCategoryDto } from './dto/update-category.dto'; @@ -19,32 +19,27 @@ export class CategoriesController { constructor(private readonly categoriesService: CategoriesService) {} @Post() - @ApiCreatedResponse({ type: CategoryEntity }) - async create(@Body() createCategoryDto: CreateCategoryDto) { + async create(@Body() createCategoryDto: CreateCategoryDto): Promise<CategoryEntity> { return await this.categoriesService.create(createCategoryDto); } @Get() - @ApiOkResponse({ type: [CategoryEntity] }) - async findAll() { + async findAll(): Promise<CategoryEntity[]> { return await this.categoriesService.findAll(); } @Get(':id') - @ApiOkResponse({ type: CategoryEntity }) - async findOne(@Param('id') id: string) { + async findOne(@Param('id') id: string): Promise<CategoryEntity> { return await this.categoriesService.findOne(id); } @Patch(':id') - @ApiOkResponse({ type: CategoryEntity }) - async update(@Param('id') id: string, @Body() updateCategoryDto: UpdateCategoryDto) { + async update(@Param('id') id: string, @Body() updateCategoryDto: UpdateCategoryDto): Promise<CategoryEntity> { return await this.categoriesService.update(id, updateCategoryDto); } @Delete(':id') - @ApiOkResponse({ type: CategoryEntity }) - async remove(@Param('id') id: string) { + async remove(@Param('id') id: string): Promise<CategoryEntity> { return await this.categoriesService.remove(id); } } -- GitLab