Skip to content

Commit

Permalink
feat: allow to specify action name in @action
Browse files Browse the repository at this point in the history
  • Loading branch information
loopingz committed Nov 29, 2023
1 parent c3524da commit ed1429f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/core/src/models/coremodel.ts
Expand Up @@ -343,7 +343,7 @@ const ActionsAnnotated: Map<any, ModelActions> = new Map();
* @param target
* @param propertyKey
*/
export function Action(options: { methods?: HttpMethodType[]; openapi?: any } = {}) {
export function Action(options: { methods?: HttpMethodType[]; openapi?: any; name?: string } = {}) {
return function (target: any, propertyKey: string) {
let custom: Record<"Actions", ModelActions> = target;
const global = typeof target === "function";
Expand All @@ -354,7 +354,7 @@ export function Action(options: { methods?: HttpMethodType[]; openapi?: any } =
ActionsAnnotated.set(custom, {});
}
const actions = ActionsAnnotated.get(custom);
actions[propertyKey] = {
actions[options.name || propertyKey] = {
...options,
global
};
Expand Down

0 comments on commit ed1429f

Please sign in to comment.