Refactor webhook event name generation in OpenApiService (#11592)

Fixes - #11589
POT - 
![Screenshot 2025-04-16 at 12 39
11 AM](https://github.com/user-attachments/assets/43802e1a-1ece-4b44-831f-35d70285c5fb)
This commit is contained in:
madanlal mohanrao nikalje
2025-04-16 11:33:47 +05:30
committed by GitHub
parent 981b1bd767
commit 4c2c9e4273

View File

@ -82,18 +82,24 @@ export class OpenApiService {
schema.webhooks = objectMetadataItems.reduce( schema.webhooks = objectMetadataItems.reduce(
(paths, item) => { (paths, item) => {
paths[`Create ${item.nameSingular}`] = computeWebhooks( paths[
this.createWebhookEventName(
DatabaseEventAction.CREATED, DatabaseEventAction.CREATED,
item, item.nameSingular,
); )
paths[`Update ${item.nameSingular}`] = computeWebhooks( ] = computeWebhooks(DatabaseEventAction.CREATED, item);
paths[
this.createWebhookEventName(
DatabaseEventAction.UPDATED, DatabaseEventAction.UPDATED,
item, item.nameSingular,
); )
paths[`Delete ${item.nameSingular}`] = computeWebhooks( ] = computeWebhooks(DatabaseEventAction.UPDATED, item);
paths[
this.createWebhookEventName(
DatabaseEventAction.DELETED, DatabaseEventAction.DELETED,
item, item.nameSingular,
); )
] = computeWebhooks(DatabaseEventAction.DELETED, item);
return paths; return paths;
}, },
@ -226,4 +232,11 @@ export class OpenApiService {
return schema; return schema;
} }
createWebhookEventName(
action: DatabaseEventAction,
objectName: string,
): string {
return `${capitalize(objectName)} ${capitalize(action)}`;
}
} }