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(
|
schema.webhooks = objectMetadataItems.reduce(
|
||||||
(paths, item) => {
|
(paths, item) => {
|
||||||
paths[`Create ${item.nameSingular}`] = computeWebhooks(
|
paths[
|
||||||
DatabaseEventAction.CREATED,
|
this.createWebhookEventName(
|
||||||
item,
|
DatabaseEventAction.CREATED,
|
||||||
);
|
item.nameSingular,
|
||||||
paths[`Update ${item.nameSingular}`] = computeWebhooks(
|
)
|
||||||
DatabaseEventAction.UPDATED,
|
] = computeWebhooks(DatabaseEventAction.CREATED, item);
|
||||||
item,
|
paths[
|
||||||
);
|
this.createWebhookEventName(
|
||||||
paths[`Delete ${item.nameSingular}`] = computeWebhooks(
|
DatabaseEventAction.UPDATED,
|
||||||
DatabaseEventAction.DELETED,
|
item.nameSingular,
|
||||||
item,
|
)
|
||||||
);
|
] = computeWebhooks(DatabaseEventAction.UPDATED, item);
|
||||||
|
paths[
|
||||||
|
this.createWebhookEventName(
|
||||||
|
DatabaseEventAction.DELETED,
|
||||||
|
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)}`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user