Skip to content

Commit

Permalink
refactor: change swagger operationId output
Browse files Browse the repository at this point in the history
  • Loading branch information
compojoom committed Nov 14, 2024
1 parent 461ba00 commit 495ed29
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/app.provider.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { INestApplication } from '@nestjs/common';
import { VersioningType } from '@nestjs/common';
import type { SwaggerDocumentOptions } from '@nestjs/swagger';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
import { NestFactory } from '@nestjs/core';
import { IConfigurationService } from '@/config/configuration.service.interface';
Expand All @@ -26,7 +27,16 @@ function configureSwagger(app: INestApplication): void {
.setVersion(configurationService.get('about.version') ?? '')
.build();

const document = SwaggerModule.createDocument(app, config);
const options: SwaggerDocumentOptions = {
operationIdFactory: (
_: string,
methodKey: string,
version: string | undefined,
) =>
`${version ? version : ''}${methodKey.charAt(0).toUpperCase()}${methodKey.slice(1)}`,
};

const document = SwaggerModule.createDocument(app, config, options);
SwaggerModule.setup('api', app, document, {
customfavIcon: '/favicon.png',
customSiteTitle: 'Safe Client Gateway',
Expand Down

0 comments on commit 495ed29

Please sign in to comment.