Skip to content
Snippets Groups Projects
Commit 9754c45d authored by Lukáš Kratochvíl's avatar Lukáš Kratochvíl
Browse files

feat: added category API endpoints response Swagger docs

parent 46b79247
No related branches found
No related tags found
No related merge requests found
...@@ -7,10 +7,11 @@ import { ...@@ -7,10 +7,11 @@ import {
Param, Param,
Delete, Delete,
} from '@nestjs/common'; } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger'; import { ApiCreatedResponse, ApiOkResponse, ApiTags } from '@nestjs/swagger';
import { CategoriesService } from './categories.service'; import { CategoriesService } from './categories.service';
import { CreateCategoryDto } from './dto/create-category.dto'; import { CreateCategoryDto } from './dto/create-category.dto';
import { UpdateCategoryDto } from './dto/update-category.dto'; import { UpdateCategoryDto } from './dto/update-category.dto';
import { CategoryEntity } from './entities/category.entity';
@ApiTags('categories') @ApiTags('categories')
@Controller('categories') @Controller('categories')
...@@ -18,26 +19,31 @@ export class CategoriesController { ...@@ -18,26 +19,31 @@ export class CategoriesController {
constructor(private readonly categoriesService: CategoriesService) {} constructor(private readonly categoriesService: CategoriesService) {}
@Post() @Post()
@ApiCreatedResponse({ type: CategoryEntity })
async create(@Body() createCategoryDto: CreateCategoryDto) { async create(@Body() createCategoryDto: CreateCategoryDto) {
return await this.categoriesService.create(createCategoryDto); return await this.categoriesService.create(createCategoryDto);
} }
@Get() @Get()
@ApiOkResponse({ type: [CategoryEntity] })
async findAll() { async findAll() {
return await this.categoriesService.findAll(); return await this.categoriesService.findAll();
} }
@Get(':id') @Get(':id')
@ApiOkResponse({ type: CategoryEntity })
async findOne(@Param('id') id: string) { async findOne(@Param('id') id: string) {
return await this.categoriesService.findOne(id); return await this.categoriesService.findOne(id);
} }
@Patch(':id') @Patch(':id')
@ApiOkResponse({ type: CategoryEntity })
async update(@Param('id') id: string, @Body() updateCategoryDto: UpdateCategoryDto) { async update(@Param('id') id: string, @Body() updateCategoryDto: UpdateCategoryDto) {
return await this.categoriesService.update(id, updateCategoryDto); return await this.categoriesService.update(id, updateCategoryDto);
} }
@Delete(':id') @Delete(':id')
@ApiOkResponse({ type: CategoryEntity })
async remove(@Param('id') id: string) { async remove(@Param('id') id: string) {
return await this.categoriesService.remove(id); return await this.categoriesService.remove(id);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment