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