diff --git a/src/main.ts b/src/main.ts index dc4098b..3a8519e 100644 --- a/src/main.ts +++ b/src/main.ts @@ -13,7 +13,7 @@ const initAdmin = async () => { password: String, is_admin: Boolean, }); - + const Model = mongoose.model('users', schema); await Model.deleteOne({login: 'admin'}); const salt = await bcrypt.genSalt(10); @@ -33,6 +33,11 @@ async function bootstrap() { const app = await NestFactory.create(AppModule); const options = new DocumentBuilder() + .addSecurity('apiKey', { + type: 'apiKey', + in: 'header', + name: 'Authorization', + }) .setTitle('Auth API') .setDescription('API для авторизации приложений и работы с пользователями') .setVersion('1.0.0') diff --git a/src/users/users.contoller.ts b/src/users/users.contoller.ts index b8709ac..fe23527 100644 --- a/src/users/users.contoller.ts +++ b/src/users/users.contoller.ts @@ -1,6 +1,6 @@ import {Controller, Get, Req, Post, Options, Header, Delete, HttpCode, Put} from '@nestjs/common'; -import {ApiResponse, ApiTags, ApiParam, ApiBody} from '@nestjs/swagger'; +import {ApiResponse, ApiTags, ApiParam, ApiBody, ApiSecurity} from '@nestjs/swagger'; import { ALLOW_ORIGIN_ALL, ALLOW_METHOD, @@ -37,6 +37,7 @@ import { } from './users.responses'; import {AuthService} from 'src/auth/auth.service'; +@ApiSecurity('apiKey') @Controller(USERS_CONTROLLER) @ApiTags(USERS_CONTROLLER) export class UsersController {