From 6ccfdee77d70799b97e68a1d2ced630b2838e163 Mon Sep 17 00:00:00 2001 From: Niek Candaele Date: Sat, 11 Jan 2025 14:09:58 +0100 Subject: [PATCH] feat: add operationId to api docs --- packages/lib-http/src/controllers/meta.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/lib-http/src/controllers/meta.ts b/packages/lib-http/src/controllers/meta.ts index 554ccfaf5d..b8d8225eb4 100644 --- a/packages/lib-http/src/controllers/meta.ts +++ b/packages/lib-http/src/controllers/meta.ts @@ -111,6 +111,20 @@ export class Meta { }); }); + // Add the operationId to the description, this helps users find the corresponding function call in the API client. + Object.keys(spec.paths).forEach((pathKey) => { + const pathItem = spec?.paths[pathKey]; + Object.keys(pathItem).forEach((method) => { + const operation = pathItem[method]; + // Api client exposes it as roleControllerSearch + // Current value is RoleController.search so lets adjust + // Capitalize the part after . and remove the . + const split = operation.operationId.split('.'); + const cleanOperationId = split[0] + split[1].charAt(0).toUpperCase() + split[1].slice(1); + operation.description = (operation.description || '') + `
OperationId: \`${cleanOperationId}\``; + }); + }); + if (spec.components?.schemas) { spec.components.schemas.PERMISSIONS = { enum: Object.values(PERMISSIONS),