From 1f27c9312f940759559a02d6f99e4dba51a61700 Mon Sep 17 00:00:00 2001 From: Kumari Vaishnavi <145796948+vaishnavijha12@users.noreply.github.com> Date: Sun, 26 Apr 2026 11:38:49 +0530 Subject: [PATCH 1/3] Enhance Swagger setup with API filtering and grouping Added a helper function to filter APIs by tags and created separate Swagger documents for different API groups. Signed-off-by: Kumari Vaishnavi <145796948+vaishnavijha12@users.noreply.github.com> --- apps/api-gateway/src/main.ts | 56 +++++++++++++++++++++++++++++++----- 1 file changed, 49 insertions(+), 7 deletions(-) diff --git a/apps/api-gateway/src/main.ts b/apps/api-gateway/src/main.ts index 67f0d0bb4..65710d97c 100755 --- a/apps/api-gateway/src/main.ts +++ b/apps/api-gateway/src/main.ts @@ -88,15 +88,57 @@ async function bootstrap(): Promise { }); // Create Swagger document - let document = SwaggerModule.createDocument(app, options); - try { - const ecosystemFilter = app.get(EcosystemSwaggerFilter); - document = await ecosystemFilter.filterDocument(document); - } catch (err) { - Logger.warn('Skipping EcosystemSwaggerFilter due to error', err as Error); + let document = SwaggerModule.createDocument(app, options); +try { + const ecosystemFilter = app.get(EcosystemSwaggerFilter); + document = await ecosystemFilter.filterDocument(document); +} catch (err) { + Logger.warn('Skipping EcosystemSwaggerFilter due to error', err as Error); +} + +// 🔹 Helper to filter APIs by tag +function filterByTags(doc: any, tagNames: string[]) { + const filteredPaths: any = {}; + + for (const path in doc.paths) { + const methods = doc.paths[path]; + + for (const method in methods) { + const operation = methods[method]; + + if ( + operation.tags && + operation.tags.some((tag: string) => tagNames.includes(tag)) + ) { + if (!filteredPaths[path]) filteredPaths[path] = {}; + filteredPaths[path][method] = operation; + } + } } - SwaggerModule.setup('api', app, document); + return { + ...doc, + paths: filteredPaths + }; +} +// 🔹 Create separate documents +const didcommDoc = filterByTags(document, ['connection', 'issuance', 'verification']); +const oid4vcDoc = filterByTags(document, ['oid4vc-issuance', 'oid4vc-verification']); +const utilsDoc = filterByTags(document, [ + 'utility', + 'ledger', + 'webhook', + 'geo-location', + 'notification' +]); + +// 🔹 Default full Swagger +SwaggerModule.setup('api', app, document); + +// 🔹 New grouped Swagger UIs +SwaggerModule.setup('api/didcomm', app, didcommDoc); +SwaggerModule.setup('api/oid4vc', app, oid4vcDoc); +SwaggerModule.setup('api/utils', app, utilsDoc); const httpAdapter: HttpAdapterHost = app.get(HttpAdapterHost) as HttpAdapterHost; app.useGlobalFilters(new AllExceptionsFilter(httpAdapter)); const { ENABLE_CORS_IP_LIST } = process.env || {}; From 6ae310a1e7bc5d2ee444fa383fd23fcc74139a3e Mon Sep 17 00:00:00 2001 From: Kumari Vaishnavi <145796948+vaishnavijha12@users.noreply.github.com> Date: Sun, 26 Apr 2026 17:05:12 +0530 Subject: [PATCH 2/3] fix: correct swagger tag names for proper API grouping Signed-off-by: Kumari Vaishnavi <145796948+vaishnavijha12@users.noreply.github.com> --- apps/api-gateway/src/main.ts | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/apps/api-gateway/src/main.ts b/apps/api-gateway/src/main.ts index 65710d97c..9ba62deba 100755 --- a/apps/api-gateway/src/main.ts +++ b/apps/api-gateway/src/main.ts @@ -122,16 +122,23 @@ function filterByTags(doc: any, tagNames: string[]) { }; } // 🔹 Create separate documents -const didcommDoc = filterByTags(document, ['connection', 'issuance', 'verification']); -const oid4vcDoc = filterByTags(document, ['oid4vc-issuance', 'oid4vc-verification']); +const didcommDoc = filterByTags(document, [ + 'connections', + 'verifications' +]); + +const oid4vcDoc = filterByTags(document, [ + 'OID4VC', + 'OID4VP' +]); + const utilsDoc = filterByTags(document, [ - 'utility', - 'ledger', - 'webhook', - 'geo-location', + 'utilities', + 'ledgers', + 'webhooks', + 'geolocation', 'notification' ]); - // 🔹 Default full Swagger SwaggerModule.setup('api', app, document); From cc22166d88765901c27096b16961c6eb0b84758d Mon Sep 17 00:00:00 2001 From: Kumari Vaishnavi <145796948+vaishnavijha12@users.noreply.github.com> Date: Sun, 26 Apr 2026 17:16:07 +0530 Subject: [PATCH 3/3] refactor: improve filterByTags typing and fix import placement Signed-off-by: Kumari Vaishnavi <145796948+vaishnavijha12@users.noreply.github.com> --- apps/api-gateway/src/main.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/apps/api-gateway/src/main.ts b/apps/api-gateway/src/main.ts index 9ba62deba..0ea946306 100755 --- a/apps/api-gateway/src/main.ts +++ b/apps/api-gateway/src/main.ts @@ -3,6 +3,7 @@ import * as dotenv from 'dotenv'; import * as express from 'express'; import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger'; +import { OpenAPIObject } from '@nestjs/swagger'; import { Logger, VERSION_NEUTRAL, VersioningType } from '@nestjs/common'; import * as cookieParser from 'cookie-parser'; import { AppModule } from './app.module'; @@ -97,20 +98,20 @@ try { } // 🔹 Helper to filter APIs by tag -function filterByTags(doc: any, tagNames: string[]) { - const filteredPaths: any = {}; - for (const path in doc.paths) { - const methods = doc.paths[path]; - for (const method in methods) { - const operation = methods[method]; +function filterByTags(doc: OpenAPIObject, tagNames: string[]): OpenAPIObject { + const filteredPaths: OpenAPIObject['paths'] = {}; + for (const [path, methods] of Object.entries(doc.paths)) { + for (const [method, operation] of Object.entries(methods)) { if ( operation.tags && operation.tags.some((tag: string) => tagNames.includes(tag)) ) { - if (!filteredPaths[path]) filteredPaths[path] = {}; + if (!filteredPaths[path]) { + filteredPaths[path] = {}; + } filteredPaths[path][method] = operation; } }