@@ -10,6 +10,7 @@ import {
1010 ApiProduces ,
1111 ApiQuery ,
1212 ApiResponse ,
13+ ApiSecurity ,
1314 getSchemaPath ,
1415} from '@nestjs/swagger' ;
1516import { APP_LANGUAGE } from 'src/app/constants/app.constant' ;
@@ -130,7 +131,7 @@ export function Doc<T>(
130131 }
131132
132133 if ( options ?. auth ?. apiKey ) {
133- auths . push ( ApiBearerAuth ( 'apiKey' ) ) ;
134+ auths . push ( ApiSecurity ( 'apiKey' ) ) ;
134135 oneOfUnauthorized . push (
135136 {
136137 statusCode : ENUM_API_KEY_STATUS_CODE_ERROR . API_KEY_NEEDED_ERROR ,
@@ -154,6 +155,27 @@ export function Doc<T>(
154155 ) ;
155156 }
156157
158+ if ( options ?. auth ?. permissionToken ) {
159+ auths . push ( ApiSecurity ( 'permissionToken' ) ) ;
160+ oneOfUnauthorized . push (
161+ {
162+ statusCode :
163+ ENUM_AUTH_STATUS_CODE_ERROR . AUTH_PERMISSION_TOKEN_ERROR ,
164+ messagePath : 'auth.error.permissionTokenUnauthorized' ,
165+ } ,
166+ {
167+ statusCode :
168+ ENUM_AUTH_STATUS_CODE_ERROR . AUTH_PERMISSION_TOKEN_INVALID_ERROR ,
169+ messagePath : 'auth.error.permissionTokenInvalid' ,
170+ } ,
171+ {
172+ statusCode :
173+ ENUM_AUTH_STATUS_CODE_ERROR . AUTH_PERMISSION_TOKEN_NOT_YOUR_ERROR ,
174+ messagePath : 'auth.error.permissionTokenNotYour' ,
175+ }
176+ ) ;
177+ }
178+
157179 // request headers
158180 const requestHeaders = [ ] ;
159181 if ( options ?. requestHeader ?. userAgent ) {
@@ -291,7 +313,7 @@ export function DocPaging<T>(
291313 }
292314
293315 if ( options ?. auth ?. apiKey ) {
294- auths . push ( ApiBearerAuth ( 'apiKey' ) ) ;
316+ auths . push ( ApiSecurity ( 'apiKey' ) ) ;
295317 oneOfUnauthorized . push (
296318 {
297319 statusCode : ENUM_API_KEY_STATUS_CODE_ERROR . API_KEY_NEEDED_ERROR ,
@@ -315,6 +337,27 @@ export function DocPaging<T>(
315337 ) ;
316338 }
317339
340+ if ( options ?. auth ?. permissionToken ) {
341+ auths . push ( ApiSecurity ( 'permissionToken' ) ) ;
342+ oneOfUnauthorized . push (
343+ {
344+ statusCode :
345+ ENUM_AUTH_STATUS_CODE_ERROR . AUTH_PERMISSION_TOKEN_ERROR ,
346+ messagePath : 'auth.error.permissionTokenUnauthorized' ,
347+ } ,
348+ {
349+ statusCode :
350+ ENUM_AUTH_STATUS_CODE_ERROR . AUTH_PERMISSION_TOKEN_INVALID_ERROR ,
351+ messagePath : 'auth.error.permissionTokenInvalid' ,
352+ } ,
353+ {
354+ statusCode :
355+ ENUM_AUTH_STATUS_CODE_ERROR . AUTH_PERMISSION_TOKEN_NOT_YOUR_ERROR ,
356+ messagePath : 'auth.error.permissionTokenNotYour' ,
357+ }
358+ ) ;
359+ }
360+
318361 // request headers
319362 const requestHeaders = [ ] ;
320363 if ( options ?. requestHeader ?. userAgent ) {
0 commit comments