helpers.schema - ZeMA-gGmbH/NoPE-JS GitHub Wiki

Namespace: schema

helpers.schema

Functions

flattenSchema

flattenSchema(schema, prePath?, postPath?, splitChar?, definitions?): IJsonSchema

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

Parameters

Name Type Default value Description
schema IJsonSchema undefined The Schema used as input. This will be flattend
prePath? string "root" The Name of the Schema. It is used for the "main" definition
postPath? string "" An additional path for every item which is added to the name. example "msg"
splitChar? string SPLITCHAR The char to split the elements.
definitions? IJsonSchema undefined -

Returns

IJsonSchema

The Adapted Item.


isJsonSchema

isJsonSchema(schema): boolean

A Helper Function, to test, if the given schema is a JSON Schema or whether it contains a method description

Parameters

Name Type Description
schema INopeDescriptor | IJsonSchema The Schema to Test

Returns

boolean


nestSchema

nestSchema(schema): IJsonSchema

Function to Flatten a JSON-Schema.

Parameters

Name Type
schema IJsonSchema

Returns

IJsonSchema


reduceSchema

reduceSchema(schema, getName?): IJsonSchema

Helper Function to reduce the Schema and remove multiple definitions.

Parameters

Name Type Default value
schema IJsonSchema undefined
getName (schema: IJsonSchema, names: string[]) => string _defaultCombiner

Returns

IJsonSchema


schemaGetDefinition

schemaGetDefinition(schema, reference): any

Function to get a Schemas Definition

Parameters

Name Type Description
schema IJsonSchema the JSON-Schema
reference string the path of the relevant definition.

Returns

any