Skip to content

get

@tsed/schema

Usage

typescript
import { get } from "@tsed/schema";

See /packages/specs/schema/src/fn/from.ts.

Overview

ts
function get(type: Type<any>): JsonSchema<import("json-schema").JSONSchema7Type>;
  • type (Type<any>): The class owning the shared schema metadata.

Description

Get the shared schema instance attached to a class.

Contrary to from, get() returns the schema stored in the class metadata. Mutating the returned instance updates the class-level schema definition and therefore affects every consumer of that class schema.

This helper is intended for low-level or internal patching scenarios where the source schema must be updated in place.

typescript
get(UserModel).properties({
  name: string()
});

Released under the MIT License.