typescript-json-schema

  • Version 0.65.1
  • Published
  • 262 kB
  • 8 dependencies
  • BSD-3-Clause license

Install

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

Overview

typescript-json-schema generates JSON Schema files from your Typescript sources

Index

Functions

function buildGenerator

buildGenerator: (
program: ts.Program,
args?: PartialArgs,
onlyIncludeFiles?: string[]
) => JsonSchemaGenerator | null;

    function exec

    exec: (filePattern: string, fullTypeName: string, args?: Args) => Promise<void>;

      function generateSchema

      generateSchema: (
      program: ts.Program,
      fullTypeName: string,
      args?: PartialArgs,
      onlyIncludeFiles?: string[],
      externalGenerator?: JsonSchemaGenerator
      ) => Definition | null;

        function getDefaultArgs

        getDefaultArgs: () => Args;

          function getProgramFromFiles

          getProgramFromFiles: (
          files: string[],
          jsonCompilerOptions?: any,
          basePath?: string
          ) => ts.Program;

            function programFromConfig

            programFromConfig: (
            configFileName: string,
            onlyIncludeFiles?: string[]
            ) => ts.Program;

              function regexRequire

              regexRequire: (value: string) => RegExpExecArray | null;

                Classes

                class JsonSchemaGenerator

                class JsonSchemaGenerator {}

                  constructor

                  constructor(
                  symbols: SymbolRef[],
                  allSymbols: { [name: string]: ts.Type },
                  userSymbols: { [name: string]: ts.Symbol },
                  inheritingTypes: { [baseName: string]: string[] },
                  tc: ts.TypeChecker,
                  args?: Args
                  );

                    property ReffedDefinitions

                    readonly ReffedDefinitions: { [key: string]: Definition };

                      method getMainFileSymbols

                      getMainFileSymbols: (
                      program: ts.Program,
                      onlyIncludeFiles?: string[]
                      ) => string[];

                        method getSchemaForSymbol

                        getSchemaForSymbol: (
                        symbolName: string,
                        includeReffedDefinitions?: boolean,
                        includeAllOverrides?: boolean
                        ) => Definition;

                          method getSchemaForSymbols

                          getSchemaForSymbols: (
                          symbolNames: string[],
                          includeReffedDefinitions?: boolean,
                          includeAllOverrides?: boolean
                          ) => Definition;

                            method getSymbols

                            getSymbols: (name?: string) => SymbolRef[];

                              method getUserSymbols

                              getUserSymbols: () => string[];

                                method setSchemaOverride

                                setSchemaOverride: (symbolName: string, schema: Definition) => void;

                                  Interfaces

                                  interface Definition

                                  interface Definition extends Omit<JSONSchema7, RedefinedFields> {}

                                    property additionalItems

                                    additionalItems?: DefinitionOrBoolean;

                                      property additionalProperties

                                      additionalProperties?: DefinitionOrBoolean;

                                        property allOf

                                        allOf?: DefinitionOrBoolean[];

                                          property anyOf

                                          anyOf?: DefinitionOrBoolean[];

                                            property contains

                                            contains?: JSONSchema7;

                                              property defaultProperties

                                              defaultProperties?: string[];

                                                property definitions

                                                definitions?: {
                                                [key: string]: DefinitionOrBoolean;
                                                };

                                                  property dependencies

                                                  dependencies?: {
                                                  [key: string]: DefinitionOrBoolean | string[];
                                                  };

                                                    property else

                                                    else?: DefinitionOrBoolean;

                                                      property if

                                                      if?: DefinitionOrBoolean;

                                                        property items

                                                        items?: DefinitionOrBoolean | DefinitionOrBoolean[];

                                                          property not

                                                          not?: DefinitionOrBoolean;

                                                            property oneOf

                                                            oneOf?: DefinitionOrBoolean[];

                                                              property patternProperties

                                                              patternProperties?: {
                                                              [key: string]: DefinitionOrBoolean;
                                                              };

                                                                property properties

                                                                properties?: {
                                                                [key: string]: DefinitionOrBoolean;
                                                                };

                                                                  property propertyNames

                                                                  propertyNames?: DefinitionOrBoolean;

                                                                    property propertyOrder

                                                                    propertyOrder?: string[];

                                                                      property then

                                                                      then?: DefinitionOrBoolean;

                                                                        property typeof

                                                                        typeof?: 'function';

                                                                          Type Aliases

                                                                          type Args

                                                                          type Args = {
                                                                          ref: boolean;
                                                                          aliasRef: boolean;
                                                                          topRef: boolean;
                                                                          titles: boolean;
                                                                          defaultProps: boolean;
                                                                          noExtraProps: boolean;
                                                                          propOrder: boolean;
                                                                          typeOfKeyword: boolean;
                                                                          required: boolean;
                                                                          strictNullChecks: boolean;
                                                                          esModuleInterop: boolean;
                                                                          skipLibCheck: boolean;
                                                                          ignoreErrors: boolean;
                                                                          experimentalDecorators: boolean;
                                                                          out: string;
                                                                          validationKeywords: string[];
                                                                          include: string[];
                                                                          excludePrivate: boolean;
                                                                          uniqueNames: boolean;
                                                                          rejectDateType: boolean;
                                                                          id: string;
                                                                          defaultNumberType: 'number' | 'integer';
                                                                          tsNodeRegister: boolean;
                                                                          constAsEnum: boolean;
                                                                          };

                                                                            type DefinitionOrBoolean

                                                                            type DefinitionOrBoolean = Definition | boolean;

                                                                              type PartialArgs

                                                                              type PartialArgs = Partial<Args>;

                                                                                type PrimitiveType

                                                                                type PrimitiveType = number | boolean | string | null;

                                                                                  type SymbolRef

                                                                                  type SymbolRef = {
                                                                                  name: string;
                                                                                  typeName: string;
                                                                                  fullyQualifiedName: string;
                                                                                  symbol: ts.Symbol;
                                                                                  };

                                                                                    type ValidationKeywords

                                                                                    type ValidationKeywords = {
                                                                                    [prop: string]: boolean;
                                                                                    };

                                                                                      Package Files (1)

                                                                                      Dependencies (8)

                                                                                      Dev Dependencies (10)

                                                                                      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/typescript-json-schema.

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