@tsed/schema
Version:
JsonSchema module for Ts.ED Framework
38 lines (37 loc) • 960 B
JavaScript
import { JsonEntityFn } from "./jsonEntityFn.js";
/**
* Set a custom key on JsonSchema that is not a part of the official spec.
*
* This custom key can only be displayed if the @@getJsonSchema@@ is called with `{customKeys: true}`.
*
* @returns {Function}
* @decorator
* @validation
* @property
* @parameter
* @schema
*/
export function CustomKey(key, value) {
return JsonEntityFn((store) => {
store.itemSchema.customKey(key, value);
});
}
/**
* Set a group of custom keys on JsonSchema that is not a part of the official spec.
*
* This custom key can only be displayed if the @@getJsonSchema@@ is called with `{customKeys: true}`.
*
* @returns {Function}
* @decorator
* @validation
* @property
* @parameter
* @schema
*/
export function CustomKeys(obj) {
return JsonEntityFn((store) => {
Object.entries(obj).forEach(([key, value]) => {
store.itemSchema.customKey(key, value);
});
});
}