HM-115. Добавлено описание ответов ручек me edit-me в swagger

This commit is contained in:
vigdorov
2020-08-08 09:42:55 +03:00
parent 1bb5bd88bc
commit 96d3232f9f
2 changed files with 23 additions and 0 deletions

View File

@ -29,6 +29,8 @@ import {
UPDATE_NOT_VALID, UPDATE_NOT_VALID,
REMOVE_SUCCESS, REMOVE_SUCCESS,
REMOVE_NOT_FOUND, REMOVE_NOT_FOUND,
EDIT_ME_SUCCESS,
EDIT_ME_NOT_VALID,
} from './users.responses'; } from './users.responses';
import {AuthService} from 'src/auth/auth.service'; import {AuthService} from 'src/auth/auth.service';
@ -65,6 +67,7 @@ export class UsersController {
@Get('me') @Get('me')
@Header(...ALLOW_ORIGIN_ALL) @Header(...ALLOW_ORIGIN_ALL)
@ApiResponse(FIND_ONE_SUCCESS)
async findMe(@Req() request: Request): Promise<UserResponse> { async findMe(@Req() request: Request): Promise<UserResponse> {
await this.authService.checkRequest(request); await this.authService.checkRequest(request);
@ -73,6 +76,8 @@ export class UsersController {
@Post('edit-me') @Post('edit-me')
@Header(...ALLOW_ORIGIN_ALL) @Header(...ALLOW_ORIGIN_ALL)
@ApiResponse(EDIT_ME_SUCCESS)
@ApiResponse(EDIT_ME_NOT_VALID)
async findEdit(@Req() request: Request<null, UpdateUserSelf>): Promise<UserResponse> { async findEdit(@Req() request: Request<null, UpdateUserSelf>): Promise<UserResponse> {
await this.authService.checkRequest(request); await this.authService.checkRequest(request);

View File

@ -78,3 +78,21 @@ export const REMOVE_NOT_FOUND: ApiResponseOptions = {
description: 'Ошибка при попытке удалить пользователя с несуществующим логином', description: 'Ошибка при попытке удалить пользователя с несуществующим логином',
type: Error, type: Error,
}; };
export const FIND_ME_SUCCESS: ApiResponseOptions = {
status: 200,
description: 'Объект пользователя, который сделал запрос',
type: UserResponse,
};
export const EDIT_ME_SUCCESS: ApiResponseOptions = {
status: 200,
description: 'Обновленный объект пользователя, который сделал запрос',
type: UserResponse,
};
export const EDIT_ME_NOT_VALID: ApiResponseOptions = {
status: 400,
description: 'Ошибка при попытке обновить пользователя с невалидными полями',
type: Error,
};