swagger update
This commit is contained in:
@ -10,7 +10,7 @@
|
||||
"build": "nest build",
|
||||
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
||||
"start": "nest start",
|
||||
"start:dev": "nest start --watch",
|
||||
"dev": "nest start --watch",
|
||||
"start:debug": "nest start --debug --watch",
|
||||
"start:prod": "node dist/main",
|
||||
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { Controller, Get, Post, Body, Param, Options, Header, Delete, HttpCode, Put } from '@nestjs/common';
|
||||
import {StoreService} from './store.service';
|
||||
import {Store, StoreRequest} from './store.schema';
|
||||
import {ApiResponse} from '@nestjs/swagger';
|
||||
import {ApiResponse, ApiTags, ApiParam, ApiBody} from '@nestjs/swagger';
|
||||
import {ALLOW_ORIGIN_ALL, ALLOW_METHOD, ALLOW_CREDENTIALS, CONTENT_LENGTH, ALLOW_HEADERS} from 'src/consts';
|
||||
|
||||
const prepareStoreToStoreRequest = ({
|
||||
@ -11,6 +11,7 @@ const prepareStoreToStoreRequest = ({
|
||||
});
|
||||
|
||||
@Controller('store')
|
||||
@ApiTags('store')
|
||||
export class StoreController {
|
||||
constructor(
|
||||
private readonly storeService: StoreService
|
||||
@ -35,6 +36,10 @@ export class StoreController {
|
||||
description: 'Возвращает пару ключ-значение по ключу',
|
||||
type: StoreRequest,
|
||||
})
|
||||
@ApiParam({
|
||||
name: 'key',
|
||||
description: 'Уникальный ключ для получения api',
|
||||
})
|
||||
async findOne(@Param() {key}: {key: string}): Promise<StoreRequest> {
|
||||
const store = await this.storeService.findOne(key);
|
||||
return prepareStoreToStoreRequest(store);
|
||||
@ -47,6 +52,10 @@ export class StoreController {
|
||||
description: 'Создает новую пару ключ-значение',
|
||||
type: StoreRequest,
|
||||
})
|
||||
@ApiBody({
|
||||
type: StoreRequest,
|
||||
description: 'Принимает объект для создания api'
|
||||
})
|
||||
async create(@Body() createStoreClass: StoreRequest): Promise<StoreRequest> {
|
||||
const store = await this.storeService.create(createStoreClass);
|
||||
return prepareStoreToStoreRequest(store);
|
||||
@ -59,6 +68,10 @@ export class StoreController {
|
||||
description: 'Обновляет по ключу объект и мета-поля, кроме author',
|
||||
type: StoreRequest,
|
||||
})
|
||||
@ApiBody({
|
||||
type: StoreRequest,
|
||||
description: 'Принимает объект для обновления api'
|
||||
})
|
||||
async update(@Body() updateStoreClass: StoreRequest): Promise<StoreRequest> {
|
||||
const store = await this.storeService.update(updateStoreClass);
|
||||
return prepareStoreToStoreRequest(store);
|
||||
@ -71,6 +84,10 @@ export class StoreController {
|
||||
description: 'Удаляет пару ключ-значение по ключу',
|
||||
type: StoreRequest,
|
||||
})
|
||||
@ApiParam({
|
||||
name: 'key',
|
||||
description: 'Уникальный ключ для удаления api',
|
||||
})
|
||||
async removeOne(@Param() {key}: {key: string}): Promise<StoreRequest> {
|
||||
const store = await this.storeService.removeOne(key);
|
||||
return prepareStoreToStoreRequest(store);
|
||||
|
||||
Reference in New Issue
Block a user