UNPKG

nope-js-node

Version:

NoPE Runtime for Nodejs. For Browser-Support please use nope-browser

47 lines (46 loc) 2 kB
/** * @author Martin Karkowski * @email m.karkowski@zema.de * @desc [description] */ import { IJsonSchema } from "../types/IJSONSchema"; import { INopeDescriptor } from "../types/nope"; /** * Function to Flatten a JSON-Schema. * @param schema */ export declare function nestSchema(schema: IJsonSchema): IJsonSchema; /** * Function to get a Schemas Definition * @param schema the JSON-Schema * @param reference the path of the relevant definition. */ export declare function schemaGetDefinition(schema: IJsonSchema, reference: string): any; /** * A Helper to flatten a schema. This will add additional "$ref" items instead of nested items. * This will perhaps help to reduce the amount of data. * * @author M.Karkowski * @export * @param {IJsonSchema} schema The Schema used as input. This will be flattend * @param {string} [prePath="root"] The Name of the Schema. It is used for the "main" definition * @param {string} [postPath=""] An additional path for every item which is added to the name. example "msg" * @param {*} [splitChar=SPLITCHAR] The char to split the elements. * @param {IJsonSchema} [definitions={ definitions: {} }] A Set of defintions to be used. * @return {IJsonSchema} The Adapted Item. */ export declare function flattenSchema(schema: IJsonSchema, prePath?: string, postPath?: string, splitChar?: string, definitions?: IJsonSchema): IJsonSchema; /** * Helper Function to reduce the Schema and remove multiple definitions. * @param schema * @param getName * @returns */ export declare function reduceSchema(schema: IJsonSchema, getName?: (schema: IJsonSchema, names: string[]) => string): IJsonSchema; /** * A Helper Function, to test, if the given schema is a JSON Schema or whether it contains a method description * * @param { INopeDescriptor | IJsonSchema } schema The Schema to Test * @returns {boolean} */ export declare function isJsonSchema(schema: INopeDescriptor | IJsonSchema): boolean;