Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add operationId to api docs #1878

Merged
merged 1 commit into from
Jan 11, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading