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 aed582f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 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,15 @@ 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 aed582f

Please sign in to comment.