Skip to content

Commit 547233a

Browse files
committed
feat: add x-api-key to swagger
1 parent 17b8d2e commit 547233a

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

src/common/decorators/controller.decorator.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ import {
66
UseGuards,
77
UseInterceptors,
88
} from '@nestjs/common';
9-
import { ApiTags } from '@nestjs/swagger';
9+
import { ApiSecurity, ApiTags } from '@nestjs/swagger';
1010
import { TokenAuthGuard } from 'src/auth/guards/token-auth.guard';
1111
import { RemoveSystemFieldsInterceptor } from '../interceptor/remove-system-field.interceptor';
1212

1313
export const Controller = (name: string, tag?: string) => {
1414
return applyDecorators(
15+
ApiSecurity('X-API-KEY'),
1516
UseInterceptors(RemoveSystemFieldsInterceptor),
1617
UseGuards(TokenAuthGuard),
1718
ControllerDecorator(name),

src/main.ts

+1-5
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,7 @@ async function bootstrap() {
4040
.setDescription(
4141
'Документация для API kinopoisk.dev. API позволяет получать максимум информации с кинопоиска о фильмах, сериалах и персонах и т.д.',
4242
)
43-
.addApiKey({
44-
type: 'apiKey',
45-
name: 'token',
46-
in: 'query',
47-
})
43+
.addApiKey({ type: 'apiKey', name: 'X-API-KEY', in: 'header' }, 'X-API-KEY')
4844
.build();
4945
const document = SwaggerModule.createDocument(app, config);
5046
SwaggerModule.setup(docGlobalPrefix, app, document);

0 commit comments

Comments
 (0)