---
meta:
 - name: keywords
   description: api typescript node.js documentation JsonSchemaOptions interface
---
# JsonSchemaOptions - @tsed/schema

## Usage

```typescript
import { JsonSchemaOptions } from "@tsed/schema";
```

> See [/packages/specs/schema/src/interfaces/JsonSchemaOptions.ts](https://github.com/tsedio/tsed/blob/v8.27.0/packages/specs/schema/src/interfaces/JsonSchemaOptions.ts#L0-L0).

## Overview

```ts
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 -->

## 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

```typescript
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);
```

<!-- Members -->

## useAlias

```ts
useAlias?: boolean;
```

Map properties with the alias name. By default, false

## components

```ts
components?: Record<string, any>;
```

Reference to components Object.

## specType

```ts
specType?: SpecTypes;
```

Define Spec types level

## specVersion

```ts
specVersion?: string;
```

Define the spec version for OPENAPI (3.1.0, 3.0.3, 3.0.2, 3.0.1, 3.0.0)

## groups

```ts
groups?: string[] | false;
```

Define a group restriction to generate the JsonSchema.
Set false to disable groups.

## groupsName

```ts
groupsName?: string;
```

Set the postfix groups name for a generated model and ref.

## customKeys

```ts
customKeys?: boolean;
```

Generate custom keys when SpecType is JSON.

## inlineEnums

```ts
inlineEnums?: boolean;
```

Inline enums when enum instead of using $ref.

## generics

```ts
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]

```ts
[key: string]: any;
```
