@tsed/schema
Version:
JsonSchema module for Ts.ED Framework
24 lines (23 loc) • 580 B
JavaScript
import { DecoratorTypes } from "@tsed/core";
import { JsonEntityFn } from "./jsonEntityFn.js";
/**
* Add optional annotation on Property or Parameter.
*
* @decorator
* @validation
* @swagger
* @schema
* @input
*/
export function Optional() {
return JsonEntityFn((store) => {
switch (store.decoratorType) {
case DecoratorTypes.PARAM:
store.required = false;
break;
case DecoratorTypes.PROP:
store.parentSchema.removeRequired(store.propertyName);
break;
}
});
}