Page Contents

Home > @loopback/repository-json-schema

repository-json-schema package

Convert a TypeScript class/model to a JSON Schema for users, leveraging LoopBack4’s decorators, metadata, and reflection system.

Remarks

Modules to easily convert LoopBack4 models that have been decorated with @model and @property to a matching JSON Schema Definition.

Functions

Function Description

getFieldsJsonSchemaFor(modelCtor, options)

Build a JSON schema describing the format of the “fields” object used to include or exclude properties of model instances.

getFilterJsonSchemaFor(modelCtor, options)

Build a JSON schema describing the format of the “filter” object used to query model instances.

Note we don’t take the model properties into account yet and return a generic json schema allowing any “where” condition.

getJsonSchema(ctor, options)

Gets the JSON Schema of a TypeScript model/class by seeing if one exists in a cache. If not, one is generated and then cached.

getJsonSchemaRef(modelCtor, options)

Describe the provided Model as a reference to a definition shared by multiple endpoints. The definition is included in the returned schema.

getNavigationalPropertyForRelation(relMeta, targetRef)

Checks and return navigational property definition for the relation

getScopeFilterJsonSchemaFor(modelCtor, options)

Build a JSON schema describing the format of the “scope” object used to query model instances.

Note we don’t take the model properties into account yet and return a generic json schema allowing any “where” condition.

getWhereJsonSchemaFor(modelCtor, options)

Build a JSON schema describing the format of the “where” object used to filter model instances to query, update or delete.

Note we don’t take the model properties into account yet and return a generic json schema allowing any “where” condition.

isArrayType(type)

Determines whether a given string or constructor is array type or not

metaToJsonProperty(meta)

Converts property metadata into a JSON property definition

modelToJsonSchema(ctor, jsonSchemaOptions)

Converts a TypeScript class into a JSON Schema using TypeScript’s reflection API

stringTypeToWrapper(type)

Gets the wrapper function of primitives string, number, and boolean

Interfaces

Interface Description

FilterSchemaOptions

JsonSchemaOptions

Variables

Variable Description

AnyScopeFilterSchema

JSON_SCHEMA_KEY

Metadata key used to set or retrieve repository JSON Schema

Type Aliases

Type Alias Description

Optional

Optional: From T make a set of properties by key K become optional