JsonSchemaOptions
Usage
import { JsonSchemaOptions } from "@tsed/schema";See /packages/specs/schema/src/interfaces/JsonSchemaOptions.ts.
Overview
interface JsonSchemaOptions {
useAlias?: boolean;
components?: Record<string, any>;
specType?: SpecTypes;
specVersion?: string;
groups?: string[] | false;
groupsName?: string;
customKeys?: boolean;
inlineEnums?: boolean;
generics?: GenericsMap;
[key: string]: any;
}Description
Configuration options for JSON schema generation.
These options control how JSON schemas are generated from TypeScript classes, including alias mapping, component references, spec type selection, group filtering, and custom key generation. The options affect both JSON Schema and OpenAPI specification generation.
Usage
import {getJsonSchema, JsonSchemaOptions} from "@tsed/schema";
const options: JsonSchemaOptions = {
specType: SpecTypes.OPENAPI,
specVersion: "3.0.3",
groups: ["public"],
useAlias: true,
customKeys: true
};
const schema = getJsonSchema(MyModel, options);useAlias
useAlias?: boolean;Map properties with the alias name. By default, false
components
components?: Record<string, any>;Reference to components Object.
specType
specType?: SpecTypes;Define Spec types level
specVersion
specVersion?: string;Define the spec version for OPENAPI (3.1.0, 3.0.3, 3.0.2, 3.0.1, 3.0.0)
groups
groups?: string[] | false;Define a group restriction to generate the JsonSchema. Set false to disable groups.
groupsName
groupsName?: string;Set the postfix groups name for a generated model and ref.
customKeys
customKeys?: boolean;Generate custom keys when SpecType is JSON.
inlineEnums
inlineEnums?: boolean;Inline enums when enum instead of using $ref.
generics
generics?: GenericsMap;Represents optional generic definitions that adhere to the JSON Schema standard.
This property allows the specification of generics when constructing or representing a JSON schema. It can be used to define reusable and parameterized components within the schema structure.
[key: string]
[key: string]: any;