Skip to content

Commit

Permalink
Merge pull request #1878 from gettakaro/add-operationId-to-api-docs
Browse files Browse the repository at this point in the history
Add operationId to api docs
  • Loading branch information
niekcandaele authored Jan 11, 2025
2 parents 01cbe11 + 6ccfdee commit 4b9d0d9
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/lib-http/src/controllers/meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 || '') + `<br> OperationId: \`${cleanOperationId}\``;
});
});

if (spec.components?.schemas) {
spec.components.schemas.PERMISSIONS = {
enum: Object.values(PERMISSIONS),
Expand Down

0 comments on commit 4b9d0d9

Please sign in to comment.