Skip to content

Commit

Permalink
update doc, and swagger options
Browse files Browse the repository at this point in the history
  • Loading branch information
andrechristikan committed Oct 18, 2023
1 parent 0f44ec1 commit db97035
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
8 changes: 8 additions & 0 deletions src/common/doc/decorators/doc.decorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,14 @@ export function DocAuth(options?: IDocAuthOptions) {
});
}

if (options?.google) {
docs.push(ApiBearerAuth('google'));
oneOfUnauthorized.push({
messagePath: 'auth.error.googleSSO',
statusCode: ENUM_AUTH_STATUS_CODE_ERROR.AUTH_GOOGLE_SSO_ERROR,
});
}

if (options?.apiKey) {
docs.push(ApiSecurity('apiKey'));
oneOfUnauthorized.push(
Expand Down
1 change: 1 addition & 0 deletions src/common/doc/interfaces/doc.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export interface IDocAuthOptions {
jwtAccessToken?: boolean;
jwtRefreshToken?: boolean;
apiKey?: boolean;
google?: boolean;
}

export interface IDocRequestOptions {
Expand Down
2 changes: 1 addition & 1 deletion src/modules/user/docs/user.auth.doc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function UserAuthLoginGoogleDoc(): MethodDecorator {
Doc({
operation: 'modules.auth.user',
}),
DocAuth({ apiKey: true, jwtRefreshToken: true }),
DocAuth({ google: true }),
DocResponse('user.loginGoogle')
);
}
Expand Down
10 changes: 7 additions & 3 deletions src/swagger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ export default async function (app: NestApplication) {
{ type: 'http', scheme: 'bearer', bearerFormat: 'JWT' },
'refreshToken'
)
.addBearerAuth(
{ type: 'http', scheme: 'bearer', bearerFormat: 'JWT' },
'google'
)
.addApiKey(
{ type: 'apiKey', in: 'header', name: 'x-api-key' },
'apiKey'
Expand All @@ -62,14 +66,14 @@ export default async function (app: NestApplication) {
SwaggerModule.setup(docPrefix, app, document, {
jsonDocumentUrl: `${docPrefix}/json`,
yamlDocumentUrl: `${docPrefix}/yaml`,
explorer: false,
explorer: true,
customSiteTitle: docName,
customCss: theme.getBuffer('dark'),
swaggerOptions: {
docExpansion: 'none',
docExpansion: 'list',
persistAuthorization: true,
displayOperationId: true,
operationsSorter: 'alpha',
operationsSorter: 'method',
tagsSorter: 'alpha',
tryItOutEnabled: true,
filter: true,
Expand Down

0 comments on commit db97035

Please sign in to comment.