Refactor webhook event name generation in OpenApiService (#11592)
Fixes - #11589 POT - 
This commit is contained in:
committed by
GitHub
parent
981b1bd767
commit
4c2c9e4273
@ -82,18 +82,24 @@ export class OpenApiService {
|
||||
|
||||
schema.webhooks = objectMetadataItems.reduce(
|
||||
(paths, item) => {
|
||||
paths[`Create ${item.nameSingular}`] = computeWebhooks(
|
||||
DatabaseEventAction.CREATED,
|
||||
item,
|
||||
);
|
||||
paths[`Update ${item.nameSingular}`] = computeWebhooks(
|
||||
DatabaseEventAction.UPDATED,
|
||||
item,
|
||||
);
|
||||
paths[`Delete ${item.nameSingular}`] = computeWebhooks(
|
||||
DatabaseEventAction.DELETED,
|
||||
item,
|
||||
);
|
||||
paths[
|
||||
this.createWebhookEventName(
|
||||
DatabaseEventAction.CREATED,
|
||||
item.nameSingular,
|
||||
)
|
||||
] = computeWebhooks(DatabaseEventAction.CREATED, item);
|
||||
paths[
|
||||
this.createWebhookEventName(
|
||||
DatabaseEventAction.UPDATED,
|
||||
item.nameSingular,
|
||||
)
|
||||
] = computeWebhooks(DatabaseEventAction.UPDATED, item);
|
||||
paths[
|
||||
this.createWebhookEventName(
|
||||
DatabaseEventAction.DELETED,
|
||||
item.nameSingular,
|
||||
)
|
||||
] = computeWebhooks(DatabaseEventAction.DELETED, item);
|
||||
|
||||
return paths;
|
||||
},
|
||||
@ -226,4 +232,11 @@ export class OpenApiService {
|
||||
|
||||
return schema;
|
||||
}
|
||||
|
||||
createWebhookEventName(
|
||||
action: DatabaseEventAction,
|
||||
objectName: string,
|
||||
): string {
|
||||
return `${capitalize(objectName)} ${capitalize(action)}`;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user