'How to generate the json schema without $ref?

I am trying to use typescript-json-schema to generate json schema from TS types.

TS types:

export enum BannerType {
  DEFAULT = 'default',
  CAROUSEL = 'carousel',
}
export interface BannerProps {
  /**
   * @items {"type": "string"}
   */
  type: BannerType;
}

Generate command: typescript-json-schema './types.ts' '*' -o 'jsonschema.json'

Generated json schema:

{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "definitions": {
        "BannerProps": {
            "properties": {
                "type": {
                    "$ref": "#/definitions/BannerType"
                }
            },
            "type": "object"
        },
        "BannerType": {
            "enum": [
                "carousel",
                "default"
            ],
            "type": "string"
        }
    }
}

Is there any way to generate the json schema without $ref keyword? The output I expect is:

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "definitions": {
    "BannerProps": {
      "properties": {
        "type": "string",
        "enum": [
          "carousel",
          "default"
        ],
      },
      "type": "object"
    }
  }
}

Keep the properties inside BannerProps.properties instead of referencing other BannerType schema.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source