@tsed/schema
Version:
JsonSchema module for Ts.ED Framework
28 lines (27 loc) • 722 B
JavaScript
import { getJsonEntityStore } from "../../utils/getJsonEntityStore.js";
/**
* Decorator util to compose another decorator. See @@Description@@ decorator implementation for more details.
*
* ## Usage
*
* ```typescript
* export function Description(description: any) {
* return JsonEntityFn((entity: JsonEntityStore, args: DecoratorParameters) => {
* entity.itemSchema.description(description)
* });
* }
* ```
*
* @param fn
* @decorator
* @utils
* @model
*/
export function JsonEntityFn(fn) {
return (...parameters) => {
const result = fn(getJsonEntityStore(...parameters), parameters);
if (typeof result === "function") {
result(...parameters);
}
};
}