Commit 1f953a2c authored by mingyard's avatar mingyard

feat:修改 swagger 鉴权

parent c9fa7831
import { UseGuards } from '@nestjs/common'; import { UseGuards } from '@nestjs/common';
import { AuthGuard } from '../../controller/auth/auth.guard'; import { AuthGuard } from '../../controller/auth/auth.guard';
import { ApiBearerAuth } from '@nestjs/swagger';
/** /**
* 认证 装饰器 * 认证 装饰器
...@@ -10,6 +11,7 @@ export const Auth = () => { ...@@ -10,6 +11,7 @@ export const Auth = () => {
// 装饰器由上至下求值,由下至上执行 // 装饰器由上至下求值,由下至上执行
const decorators: any[] = []; const decorators: any[] = [];
decorators.push(UseGuards(AuthGuard)); decorators.push(UseGuards(AuthGuard));
decorators.push(ApiBearerAuth());
decorators.reverse().forEach((f) => f(...args)); decorators.reverse().forEach((f) => f(...args));
}; };
......
...@@ -8,7 +8,7 @@ export const setupOpenApi = (app: INestApplication) => { ...@@ -8,7 +8,7 @@ export const setupOpenApi = (app: INestApplication) => {
'HTTP status code of 200 indicates a successful response, while any non-200 status code signifies an error response. Specifically, when the HTTP status code is 401, it means that the user is unauthenticated and needs to be redirected to the login page for authentication.', 'HTTP status code of 200 indicates a successful response, while any non-200 status code signifies an error response. Specifically, when the HTTP status code is 401, it means that the user is unauthenticated and needs to be redirected to the login page for authentication.',
) )
.setVersion('1.0') .setVersion('1.0')
.addCookieAuth('translation_session'); .addBearerAuth();
/** /**
* openapi 展示 * openapi 展示
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment