json-schema-to-typescript

  • Version 14.0.0
  • Published
  • 2.36 MB
  • 14 dependencies
  • MIT license

Install

npm i json-schema-to-typescript
yarn add json-schema-to-typescript
pnpm add json-schema-to-typescript

Overview

compile json schema to typescript typings

Index

Variables

variable DEFAULT_OPTIONS

const DEFAULT_OPTIONS: Options;

    Functions

    function compile

    compile: (
    schema: JSONSchema4,
    name: string,
    options?: Partial<Options>
    ) => Promise<string>;

      function compileFromFile

      compileFromFile: (
      filename: string,
      options?: Partial<Options>
      ) => Promise<string>;

        Classes

        class ValidationError

        class ValidationError extends Error {}

          Interfaces

          interface CustomTypeJSONSchema

          interface CustomTypeJSONSchema extends NormalizedJSONSchema {}

            property tsType

            tsType: string;

              interface EnumJSONSchema

              interface EnumJSONSchema extends NormalizedJSONSchema {}

                property enum

                enum: any[];

                  interface JSONSchema

                  interface JSONSchema extends JSONSchema4 {}

                    property deprecated

                    deprecated?: boolean;
                    • property exists at least in https://json-schema.org/draft/2019-09/json-schema-validation.html#rfc.section.9.3

                    property tsEnumNames

                    tsEnumNames?: string[];
                    • schema extension to support numeric enums

                    property tsType

                    tsType?: string;
                    • schema extension to support custom types

                    interface NamedEnumJSONSchema

                    interface NamedEnumJSONSchema extends NormalizedJSONSchema {}

                      property tsEnumNames

                      tsEnumNames: string[];

                        interface Options

                        interface Options {}

                          property $refOptions

                          $refOptions: $RefOptions;
                          • [$RefParser](https://github.com/APIDevTools/json-schema-ref-parser) Options, used when resolving $refs

                          property additionalProperties

                          additionalProperties: boolean;
                          • Default value for additionalProperties, when it is not explicitly set.

                          property bannerComment

                          bannerComment: string;
                          • Disclaimer comment prepended to the top of each generated file.

                          property cwd

                          cwd: string;
                          • Root directory for resolving [$ref](https://tools.ietf.org/id/draft-pbryan-zyp-json-ref-03.html)s.

                          property declareExternallyReferenced

                          declareExternallyReferenced: boolean;
                          • Declare external schemas referenced via $ref?

                          property enableConstEnums

                          enableConstEnums: boolean;
                          • Prepend enums with [const](https://www.typescriptlang.org/docs/handbook/enums.html#computed-and-constant-members)?

                          property format

                          format: boolean;
                          • Format code? Set this to false to improve performance.

                          property ignoreMinAndMaxItems

                          ignoreMinAndMaxItems: boolean;
                          • Ignore maxItems and minItems for array types, preventing tuples being generated.

                          property maxItems

                          maxItems: number;
                          • Maximum number of unioned tuples to emit when representing bounded-size array types, before falling back to emitting unbounded arrays. Increase this to improve precision of emitted types, decrease it to improve performance, or set it to -1 to ignore minItems and maxItems.

                          property strictIndexSignatures

                          strictIndexSignatures: boolean;
                          • Append all index signatures with | undefined so that they are strictly typed.

                            This is required to be compatible with strictNullChecks.

                          property style

                          style: PrettierOptions;
                          • A [Prettier](https://prettier.io/docs/en/options.html) configuration.

                          property unknownAny

                          unknownAny: boolean;
                          • Generate unknown type instead of any

                          property unreachableDefinitions

                          unreachableDefinitions: boolean;
                          • Generate code for definitions that aren't referenced by the schema?

                          Package Files (2)

                          Dependencies (14)

                          Dev Dependencies (22)

                          Peer Dependencies (0)

                          No peer dependencies.

                          Badge

                          To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                          You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/json-schema-to-typescript.

                          • Markdown
                            [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/json-schema-to-typescript)
                          • HTML
                            <a href="https://www.jsdocs.io/package/json-schema-to-typescript"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>