ts-json-schema-generator
- Version 2.5.0
- Published
- 939 kB
- 7 dependencies
- MIT license
Install
npm i ts-json-schema-generatoryarn add ts-json-schema-generatorpnpm add ts-json-schema-generatorOverview
Generate JSON schema from your Typescript sources
Index
Variables
Functions
- createFormatter()
- createGenerator()
- createParser()
- createProgram()
- deepMerge()
- derefAliasedType()
- derefAnnotatedType()
- derefType()
- extractLiterals()
- getAllOfDefinitionReducer()
- getKey()
- getNamedArguments()
- getTypeByKey()
- getTypeKeys()
- getTypeName()
- hash()
- hasJsDocTag()
- hasModifier()
- intersectionOfArrays()
- isAssignableTo()
- isDeepLiteralUnion()
- isErroredUnknownType()
- isHiddenType()
- isLiteralUnion()
- isNodeHidden()
- isPublic()
- isStatic()
- makeNullable()
- narrowType()
- notNever()
- preserveAnnotation()
- removeUndefined()
- removeUnreachable()
- strip()
- symbolAtNode()
- toEnumType()
- translate()
- typeName()
- uniqueArray()
- uniqueTypeArray()
Classes
Interfaces
Type Aliases
Variables
variable DEFAULT_CONFIG
const DEFAULT_CONFIG: Omit< Required<Config>, 'path' | 'type' | 'schemaId' | 'tsconfig' | 'tsProgram'>;variable intrinsicMethods
const intrinsicMethods: Record<string, (v: string) => string>;Functions
function createFormatter
createFormatter: ( config: CompletedConfig, augmentor?: FormatterAugmentor) => TypeFormatter;function createGenerator
createGenerator: (config: Config) => SchemaGenerator;function createParser
createParser: ( program: ts.Program, config: CompletedConfig, augmentor?: ParserAugmentor) => NodeParser;function createProgram
createProgram: (config: CompletedConfig) => ts.Program;function deepMerge
deepMerge: ( a: { [key: string]: JSONSchema7Definition }, b: { [key: string]: JSONSchema7Definition }) => { [x: string]: JSONSchema7Definition };Merges nested objects and arrays.
Parameter a
lhs to merge.
Parameter b
rhs to merge.
Parameter intersectArrays
compute intersection of arrays (otherwise take the array from b).
Returns
a and b merged together.
function derefAliasedType
derefAliasedType: (type: BaseType) => BaseType;function derefAnnotatedType
derefAnnotatedType: (type: BaseType) => BaseType;function derefType
derefType: (type: BaseType) => BaseType;Dereference the type as far as possible.
function extractLiterals
extractLiterals: (type: BaseType) => string[];function getAllOfDefinitionReducer
getAllOfDefinitionReducer: ( childTypeFormatter: TypeFormatter) => (definition: JSONSchema7, baseType: BaseType) => JSONSchema7;function getKey
getKey: (node: Node, context: Context) => string;function getNamedArguments
getNamedArguments: ( childNodeParser: NodeParser, node: | ts.FunctionTypeNode | ts.FunctionExpression | ts.FunctionDeclaration | ts.ArrowFunction | ts.ConstructorTypeNode, context: Context) => ObjectType | undefined;function getTypeByKey
getTypeByKey: ( type: BaseType, index: LiteralType | StringType | NumberType) => BaseType | undefined;function getTypeKeys
getTypeKeys: (type: BaseType) => LiteralType[];function getTypeName
getTypeName: ( node: | ts.FunctionTypeNode | ts.FunctionExpression | ts.FunctionDeclaration | ts.ArrowFunction | ts.ConstructorTypeNode) => string | undefined;function hash
hash: ( a: | string | boolean | number | (string | boolean | number | Record<string, unknown>)[] | Record<string, unknown>) => string | number;function hasJsDocTag
hasJsDocTag: (node: ts.Node, tagName: string) => boolean;function hasModifier
hasModifier: (node: ts.HasModifiers, modifier: ts.SyntaxKind) => boolean;Checks if given node has the given modifier.
Parameter node
The node to check.
Parameter modifier
The modifier to look for. True if node has the modifier, false if not.
function intersectionOfArrays
intersectionOfArrays: <T>(a: T[], b: T[]) => T[];function isAssignableTo
isAssignableTo: ( target: BaseType, source: BaseType, inferMap?: Map<string, BaseType>, insideTypes?: Set<BaseType>) => boolean;Checks if given source type is assignable to given target type.
The logic of this function is heavily inspired by https://github.com/runem/ts-simple-type/blob/master/src/is-assignable-to-simple-type.ts
Parameter source
The source type.
Parameter target
The target type.
Parameter inferMap
Optional parameter that keeps track of the inferred types.
Parameter insideTypes
Optional parameter used internally to solve circular dependencies. True if source type is assignable to target type.
function isDeepLiteralUnion
isDeepLiteralUnion: (type: BaseType) => boolean;Recursively checks whether the given type is a union composed entirely of literal types.
function isErroredUnknownType
isErroredUnknownType: (type: BaseType) => type is UnknownType;Checks for an UnknownType with an errored source.
function isHiddenType
isHiddenType: (type: BaseType) => boolean;function isLiteralUnion
isLiteralUnion: (type: UnionType) => boolean;function isNodeHidden
isNodeHidden: (node: ts.Node) => boolean;function isPublic
isPublic: (node: ts.HasModifiers) => boolean;Checks if given node is public. A node is public if it has the public modifier or has no modifiers at all.
Parameter node
The node to check. True if node is public, false if not.
function isStatic
isStatic: (node: ts.HasModifiers) => boolean;Checks if given node has the static modifier.
Parameter node
The node to check. True if node is static, false if not.
function makeNullable
makeNullable: (def: JSONSchema7) => JSONSchema7;function narrowType
narrowType: (type: BaseType, predicate: (type: BaseType) => boolean) => BaseType;Narrows the given type by passing all variants to the given predicate function. So when type is a union type then the predicate function is called for each type within the union and only the types for which this function returns true will remain in the returned type. Union types with only one sub type left are replaced by this one-and-only type. Empty union types are removed completely. Definition types are kept if possible. When in the end none of the type candidates match the predicate then undefined is returned.
Parameter type
The type to narrow down.
Parameter predicate
The predicate function to filter the type variants. If it returns true then the type variant is kept, when returning false it is removed. The narrowed down type.
function notNever
notNever: (x: BaseType) => boolean;function preserveAnnotation
preserveAnnotation: (originalType: BaseType, newType: BaseType) => BaseType;Return the new type wrapped in an annotated type with the same annotations as the original type.
Parameter originalType
The original type. If this is an annotated type, then the returned type will be wrapped with the same annotations.
Parameter newType
The type to be wrapped.
function removeUndefined
removeUndefined: (propertyType: UnionType) => { numRemoved: number; newType: BaseType;};Remove undefined types from union type. Returns the number of non-undefined properties.
function removeUnreachable
removeUnreachable: ( rootTypeDefinition: Definition | undefined, definitions: StringMap<Definition>) => StringMap<Definition>;function strip
strip: (input: string, chars?: Set<string>) => string;function symbolAtNode
symbolAtNode: (node: ts.Node) => ts.Symbol | undefined;function toEnumType
toEnumType: ( types: JSONSchema7TypeName[]) => JSONSchema7TypeName | JSONSchema7TypeName[];Unwraps the array if it contains only one type.
function translate
translate: (types: BaseType[]) => BaseType;Translates the given intersection type into a union type if necessary so
A & (B | C)becomes(A & B) | (A & C). If no translation is needed then the original intersection type is returned.
function typeName
typeName: (value: JSONSchema7Type) => JSONSchema7TypeName;function uniqueArray
uniqueArray: <T>(array: readonly T[]) => T[];function uniqueTypeArray
uniqueTypeArray: <T extends BaseType>(types: T[]) => T[];Classes
class AliasType
class AliasType extends BaseType {}constructor
constructor(id: string, type: BaseType);method getId
getId: () => string;method getType
getType: () => BaseType;class AliasTypeFormatter
class AliasTypeFormatter implements SubTypeFormatter {}constructor
constructor(childTypeFormatter: TypeFormatter);property childTypeFormatter
protected childTypeFormatter: TypeFormatter;method getChildren
getChildren: (type: AliasType) => BaseType[];method getDefinition
getDefinition: (type: AliasType) => JSONSchema7;method supportsType
supportsType: (type: BaseType) => boolean;class AnnotatedNodeParser
class AnnotatedNodeParser implements SubNodeParser {}constructor
constructor( childNodeParser: SubNodeParser, annotationsReader: AnnotationsReader);property annotationsReader
protected annotationsReader: AnnotationsReader;property childNodeParser
protected childNodeParser: SubNodeParser;method createType
createType: ( node: ts.Node, context: Context, reference?: ReferenceType) => BaseType;method getAnnotatedNode
protected getAnnotatedNode: (node: ts.Node) => ts.Node;method getNullable
protected getNullable: (annotatedNode: ts.Node) => boolean;method supportsNode
supportsNode: (node: ts.Node) => boolean;class AnnotatedType
class AnnotatedType extends BaseType {}constructor
constructor(type: BaseType, annotations: Annotations, nullable: boolean);method getAnnotations
getAnnotations: () => Annotations;method getId
getId: () => string;method getType
getType: () => BaseType;method isNullable
isNullable: () => boolean;class AnnotatedTypeFormatter
class AnnotatedTypeFormatter implements SubTypeFormatter {}constructor
constructor(childTypeFormatter: TypeFormatter);property childTypeFormatter
protected childTypeFormatter: TypeFormatter;method getChildren
getChildren: (type: AnnotatedType) => BaseType[];method getDefinition
getDefinition: (type: AnnotatedType) => JSONSchema7;method supportsType
supportsType: (type: BaseType) => boolean;class AnyTypeFormatter
class AnyTypeFormatter implements SubTypeFormatter {}method getChildren
getChildren: (type: AnyType) => BaseType[];method getDefinition
getDefinition: (type: AnyType) => JSONSchema7;method supportsType
supportsType: (type: BaseType) => boolean;class AnyTypeNodeParser
class AnyTypeNodeParser implements SubNodeParser {}method createType
createType: (node: ts.KeywordTypeNode, context: Context) => BaseType;method supportsNode
supportsNode: (node: ts.KeywordTypeNode) => boolean;class ArrayLiteralExpressionNodeParser
class ArrayLiteralExpressionNodeParser implements SubNodeParser {}constructor
constructor(childNodeParser: NodeParser);property childNodeParser
protected childNodeParser: NodeParser;method createType
createType: (node: ts.ArrayLiteralExpression, context: Context) => BaseType;method supportsNode
supportsNode: (node: ts.ArrayLiteralExpression) => boolean;class ArrayNodeParser
class ArrayNodeParser implements SubNodeParser {}constructor
constructor(childNodeParser: NodeParser);property childNodeParser
protected childNodeParser: NodeParser;method createType
createType: (node: ts.ArrayTypeNode, context: Context) => BaseType;method supportsNode
supportsNode: (node: ts.ArrayTypeNode) => boolean;class ArrayType
class ArrayType extends BaseType {}constructor
constructor(item: BaseType);method getId
getId: () => string;method getItem
getItem: () => BaseType;class ArrayTypeFormatter
class ArrayTypeFormatter implements SubTypeFormatter {}constructor
constructor(childTypeFormatter: TypeFormatter);method getChildren
getChildren: (type: ArrayType) => BaseType[];method getDefinition
getDefinition: (type: ArrayType) => JSONSchema7;method supportsType
supportsType: (type: BaseType) => boolean;class AsExpressionNodeParser
class AsExpressionNodeParser implements SubNodeParser {}constructor
constructor(childNodeParser: NodeParser);property childNodeParser
protected childNodeParser: NodeParser;method createType
createType: (node: ts.AsExpression, context: Context) => BaseType;method supportsNode
supportsNode: (node: ts.AsExpression) => boolean;class BaseError
abstract class BaseError extends Error {}Base error for ts-json-schema-generator
constructor
constructor(diagnostic: PartialDiagnostic);property diagnostic
readonly diagnostic: ts.Diagnostic;method createDiagnostic
static createDiagnostic: (diagnostic: PartialDiagnostic) => ts.Diagnostic;method format
format: (isTTY?: string | boolean) => string;class BaseType
abstract class BaseType {}class BasicAnnotationsReader
class BasicAnnotationsReader implements AnnotationsReader {}constructor
constructor(extraTags?: Set<string>);method getAnnotations
getAnnotations: (node: ts.Node) => Annotations | undefined;class BooleanLiteralNodeParser
class BooleanLiteralNodeParser implements SubNodeParser {}method createType
createType: (node: ts.BooleanLiteral, context: Context) => BaseType;method supportsNode
supportsNode: (node: ts.BooleanLiteral) => boolean;class BooleanType
class BooleanType extends PrimitiveType {}method getId
getId: () => string;class BooleanTypeFormatter
class BooleanTypeFormatter implements SubTypeFormatter {}method getChildren
getChildren: (type: BooleanType) => BaseType[];method getDefinition
getDefinition: (type: BooleanType) => JSONSchema7;method supportsType
supportsType: (type: BaseType) => boolean;class BooleanTypeNodeParser
class BooleanTypeNodeParser implements SubNodeParser {}method createType
createType: (node: ts.KeywordTypeNode, context: Context) => BaseType;method supportsNode
supportsNode: (node: ts.KeywordTypeNode) => boolean;class BuildError
class BuildError extends BaseError {}constructor
constructor(diag: Omit<PartialDiagnostic, 'code'>);class CallExpressionParser
class CallExpressionParser implements SubNodeParser {}constructor
constructor(typeChecker: ts.TypeChecker, childNodeParser: NodeParser);property childNodeParser
protected childNodeParser: NodeParser;property typeChecker
protected typeChecker: ts.TypeChecker;method createSubContext
protected createSubContext: ( node: ts.CallExpression, parentContext: Context) => Context;method createType
createType: (node: ts.CallExpression, context: Context) => BaseType;method supportsNode
supportsNode: (node: ts.CallExpression) => boolean;class ChainNodeParser
class ChainNodeParser implements SubNodeParser, MutableParser {}constructor
constructor(typeChecker: ts.TypeChecker, nodeParsers: SubNodeParser[]);property nodeParsers
protected nodeParsers: SubNodeParser[];property typeCaches
protected readonly typeCaches: WeakMap<ts.Node, Map<string, BaseType>>;property typeChecker
protected typeChecker: ts.TypeChecker;method addNodeParser
addNodeParser: (nodeParser: SubNodeParser) => this;method createType
createType: ( node: ts.Node, context: Context, reference?: ReferenceType) => BaseType;method getNodeParser
protected getNodeParser: (node: ts.Node) => SubNodeParser;method supportsNode
supportsNode: (node: ts.Node) => boolean;class ChainTypeFormatter
class ChainTypeFormatter implements SubTypeFormatter, MutableTypeFormatter {}constructor
constructor(typeFormatters: SubTypeFormatter[]);property typeFormatters
protected typeFormatters: SubTypeFormatter[];method addTypeFormatter
addTypeFormatter: (typeFormatter: SubTypeFormatter) => this;method getChildren
getChildren: (type: BaseType) => BaseType[];method getDefinition
getDefinition: (type: BaseType) => JSONSchema7;method getTypeFormatter
protected getTypeFormatter: (type: BaseType) => SubTypeFormatter;method supportsType
supportsType: (type: BaseType) => boolean;class CircularReferenceNodeParser
class CircularReferenceNodeParser implements SubNodeParser {}constructor
constructor(childNodeParser: SubNodeParser);property childNodeParser
protected childNodeParser: SubNodeParser;property circular
protected circular: Map<string, BaseType>;method createType
createType: (node: ts.Node, context: Context) => BaseType;method supportsNode
supportsNode: (node: ts.Node) => boolean;class CircularReferenceTypeFormatter
class CircularReferenceTypeFormatter implements SubTypeFormatter {}constructor
constructor(childTypeFormatter: SubTypeFormatter);property children
protected children: Map<BaseType, BaseType[]>;property childTypeFormatter
protected childTypeFormatter: SubTypeFormatter;property definition
protected definition: Map<BaseType, JSONSchema7>;method getChildren
getChildren: (type: BaseType) => BaseType[];method getDefinition
getDefinition: (type: BaseType) => JSONSchema7;method supportsType
supportsType: (type: BaseType) => boolean;class ConditionalTypeNodeParser
class ConditionalTypeNodeParser implements SubNodeParser {}constructor
constructor(typeChecker: ts.TypeChecker, childNodeParser: NodeParser);property childNodeParser
protected childNodeParser: NodeParser;property typeChecker
protected typeChecker: ts.TypeChecker;method createSubContext
protected createSubContext: ( node: ts.ConditionalTypeNode, parentContext: Context, checkType?: CheckType, inferMap?: Map<string, BaseType>) => Context;Creates a sub context for evaluating the sub types of the conditional type. A sub context is needed in case the check-type is a type parameter which is then narrowed down by the extends-type.
Parameter node
The reference node for the new context.
Parameter checkType
An object containing the type parameter name of the check-type, and the narrowed down check type to use for the type parameter in sub parsers.
Parameter inferMap
A map that links parameter names to their inferred types. The created sub context.
method createType
createType: (node: ts.ConditionalTypeNode, context: Context) => BaseType;method getTypeParameterName
protected getTypeParameterName: (node: ts.TypeNode) => string | null;Returns the type parameter name of the given type node if any.
Parameter node
The type node for which to return the type parameter name. The type parameter name or null if specified type node is not a type parameter.
method supportsNode
supportsNode: (node: ts.ConditionalTypeNode) => boolean;class ConstructorNodeParser
class ConstructorNodeParser implements SubNodeParser {}constructor
constructor(childNodeParser: NodeParser, functions: FunctionOptions);property childNodeParser
protected childNodeParser: NodeParser;property functions
protected functions: FunctionOptions;method createType
createType: (node: ts.ConstructorTypeNode, context: Context) => BaseType;method supportsNode
supportsNode: (node: ts.TypeNode) => boolean;class Context
class Context {}constructor
constructor(reference?: ts.Node);method getArgument
getArgument: (parameterName: string) => BaseType;method getArguments
getArguments: () => readonly BaseType[];method getCacheKey
getCacheKey: () => string;method getParameters
getParameters: () => readonly string[];method getReference
getReference: () => ts.Node | undefined;method pushArgument
pushArgument: (argumentType: BaseType) => void;method pushParameter
pushParameter: (parameterName: string) => void;method setDefault
setDefault: (parameterName: string, argumentType: BaseType) => void;class DefinitionError
class DefinitionError extends BaseError {}constructor
constructor(messageText: string, definition: JSONSchema7);property definition
readonly definition: JSONSchema7;class DefinitionType
class DefinitionType extends BaseType {}constructor
constructor(name: string, type: BaseType);method getId
getId: () => string;method getName
getName: () => string;method getType
getType: () => BaseType;class DefinitionTypeFormatter
class DefinitionTypeFormatter implements SubTypeFormatter {}constructor
constructor(childTypeFormatter: TypeFormatter, encodeRefs: boolean);property childTypeFormatter
protected childTypeFormatter: TypeFormatter;property encodeRefs
protected encodeRefs: boolean;method getChildren
getChildren: (type: DefinitionType) => BaseType[];method getDefinition
getDefinition: (type: DefinitionType) => JSONSchema7;method supportsType
supportsType: (type: BaseType) => boolean;class EnumNodeParser
class EnumNodeParser implements SubNodeParser {}constructor
constructor(typeChecker: ts.TypeChecker);property typeChecker
protected typeChecker: ts.TypeChecker;method createType
createType: ( node: ts.EnumDeclaration | ts.EnumMember, context: Context) => BaseType;method getMemberValue
protected getMemberValue: (member: ts.EnumMember, index: number) => EnumValue;method parseInitializer
protected parseInitializer: (initializer: ts.Node) => EnumValue;method supportsNode
supportsNode: (node: ts.EnumDeclaration | ts.EnumMember) => boolean;class EnumType
class EnumType extends BaseType {}constructor
constructor(id: string, values: readonly EnumValue[]);method getId
getId: () => string;method getTypes
getTypes: () => BaseType[];method getValues
getValues: () => readonly EnumValue[];class EnumTypeFormatter
class EnumTypeFormatter implements SubTypeFormatter {}method getChildren
getChildren: (type: EnumType) => BaseType[];method getDefinition
getDefinition: (type: EnumType) => JSONSchema7;method supportsType
supportsType: (type: BaseType) => boolean;class ExpectationFailedError
class ExpectationFailedError extends BaseError {}constructor
constructor(messageText: string, node?: any);property node
readonly node?: any;class ExposeNodeParser
class ExposeNodeParser implements SubNodeParser {}constructor
constructor( typeChecker: ts.TypeChecker, subNodeParser: SubNodeParser, expose: 'none' | 'all' | 'export', jsDoc: 'none' | 'extended' | 'basic');property expose
protected expose: 'none' | 'all' | 'export';property jsDoc
protected jsDoc: 'none' | 'extended' | 'basic';property subNodeParser
protected subNodeParser: SubNodeParser;property typeChecker
protected typeChecker: ts.TypeChecker;method createType
createType: ( node: ts.Node, context: Context, reference?: ReferenceType) => BaseType;method getDefinitionName
protected getDefinitionName: (node: ts.Node, context: Context) => string;method isExportNode
protected isExportNode: (node: ts.Node) => boolean;method supportsNode
supportsNode: (node: ts.Node) => boolean;class ExpressionWithTypeArgumentsNodeParser
class ExpressionWithTypeArgumentsNodeParser implements SubNodeParser {}constructor
constructor(typeChecker: ts.TypeChecker, childNodeParser: NodeParser);property childNodeParser
protected childNodeParser: NodeParser;property typeChecker
protected typeChecker: ts.TypeChecker;method createSubContext
protected createSubContext: ( node: ts.ExpressionWithTypeArguments, parentContext: Context) => Context;method createType
createType: (node: ts.ExpressionWithTypeArguments, context: Context) => BaseType;method supportsNode
supportsNode: (node: ts.ExpressionWithTypeArguments) => boolean;class ExtendedAnnotationsReader
class ExtendedAnnotationsReader extends BasicAnnotationsReader {}constructor
constructor( typeChecker: ts.TypeChecker, extraTags?: Set<string>, markdownDescription?: boolean, fullDescription?: boolean);method getAnnotations
getAnnotations: (node: ts.Node) => Annotations | undefined;method isNullable
isNullable: (node: ts.Node) => boolean;class FunctionNodeParser
class FunctionNodeParser implements SubNodeParser {}constructor
constructor(childNodeParser: NodeParser, functions: FunctionOptions);property childNodeParser
protected childNodeParser: NodeParser;property functions
protected functions: FunctionOptions;method createType
createType: ( node: | ts.FunctionTypeNode | ts.FunctionExpression | ts.FunctionDeclaration | ts.ArrowFunction, context: Context) => BaseType;method supportsNode
supportsNode: (node: ts.Node) => boolean;class FunctionType
class FunctionType extends BaseType {}constructor
constructor(node?: any, namedArguments?: ObjectType);property namedArguments
protected namedArguments?: ObjectType;method getComment
getComment: () => string | undefined;method getId
getId: () => string;method getNamedArguments
getNamedArguments: () => ObjectType | undefined;class FunctionTypeFormatter
class FunctionTypeFormatter implements SubTypeFormatter {}constructor
constructor(childTypeFormatter: TypeFormatter, functions: FunctionOptions);property childTypeFormatter
protected childTypeFormatter: TypeFormatter;property functions
protected functions: FunctionOptions;method getChildren
getChildren: (type: FunctionType) => BaseType[];method getDefinition
getDefinition: (type: FunctionType) => JSONSchema7;method supportsType
supportsType: (type: BaseType) => boolean;class HiddenNodeParser
class HiddenNodeParser implements SubNodeParser {}constructor
constructor(typeChecker: ts.TypeChecker);property typeChecker
protected typeChecker: ts.TypeChecker;method createType
createType: (_node: ts.KeywordTypeNode, _context: Context) => BaseType;method supportsNode
supportsNode: (node: ts.KeywordTypeNode) => boolean;class HiddenType
class HiddenType extends NeverType {}method getId
getId: () => string;class HiddenTypeFormatter
class HiddenTypeFormatter implements SubTypeFormatter {}method getChildren
getChildren: (type: HiddenType) => BaseType[];method getDefinition
getDefinition: (type: HiddenType) => JSONSchema7;method supportsType
supportsType: (type: BaseType) => boolean;class IndexedAccessTypeNodeParser
class IndexedAccessTypeNodeParser implements SubNodeParser {}constructor
constructor(typeChecker: ts.TypeChecker, childNodeParser: NodeParser);property childNodeParser
protected childNodeParser: NodeParser;property typeChecker
protected typeChecker: ts.TypeChecker;method createType
createType: (node: ts.IndexedAccessTypeNode, context: Context) => BaseType;method supportsNode
supportsNode: (node: ts.TypeNode) => boolean;class InterfaceAndClassNodeParser
class InterfaceAndClassNodeParser implements SubNodeParser {}constructor
constructor( typeChecker: ts.TypeChecker, childNodeParser: NodeParser, additionalProperties: boolean);property additionalProperties
protected readonly additionalProperties: boolean;property childNodeParser
protected childNodeParser: NodeParser;property typeChecker
protected typeChecker: ts.TypeChecker;method createType
createType: ( node: ts.InterfaceDeclaration | ts.ClassDeclaration, context: Context, reference?: ReferenceType) => BaseType;method getAdditionalProperties
protected getAdditionalProperties: ( node: ts.InterfaceDeclaration | ts.ClassDeclaration, context: Context) => BaseType | boolean;method getArrayItemType
protected getArrayItemType: ( node: ts.InterfaceDeclaration | ts.ClassDeclaration) => ts.TypeNode | null;If specified node extends Array or ReadonlyArray and nothing else then this method returns the array item type. In all other cases null is returned to indicate that the node is not a simple array.
Parameter node
The interface or class to check. The array item type if node is an array, null otherwise.
method getBaseTypes
protected getBaseTypes: ( node: ts.InterfaceDeclaration | ts.ClassDeclaration, context: Context) => BaseType[];method getProperties
protected getProperties: ( node: ts.InterfaceDeclaration | ts.ClassDeclaration, context: Context) => ObjectProperty[] | undefined;method getPropertyName
protected getPropertyName: (propertyName: PropertyName) => string;method getTypeId
protected getTypeId: (node: ts.Node, context: Context) => string;method supportsNode
supportsNode: (node: ts.InterfaceDeclaration | ts.ClassDeclaration) => boolean;class IntersectionNodeParser
class IntersectionNodeParser implements SubNodeParser {}constructor
constructor(typeChecker: ts.TypeChecker, childNodeParser: NodeParser);property childNodeParser
protected childNodeParser: NodeParser;property typeChecker
protected typeChecker: ts.TypeChecker;method createType
createType: (node: ts.IntersectionTypeNode, context: Context) => BaseType;method supportsNode
supportsNode: (node: ts.IntersectionTypeNode) => boolean;class IntersectionType
class IntersectionType extends BaseType {}constructor
constructor(types: BaseType[]);method getId
getId: () => string;method getTypes
getTypes: () => BaseType[];class IntersectionTypeFormatter
class IntersectionTypeFormatter implements SubTypeFormatter {}constructor
constructor(childTypeFormatter: TypeFormatter);property childTypeFormatter
protected childTypeFormatter: TypeFormatter;method getChildren
getChildren: (type: IntersectionType) => BaseType[];method getDefinition
getDefinition: (type: IntersectionType) => JSONSchema7;method supportsType
supportsType: (type: BaseType) => boolean;class IntrinsicNodeParser
class IntrinsicNodeParser implements SubNodeParser {}method createType
createType: (node: ts.KeywordTypeNode, context: Context) => BaseType;method supportsNode
supportsNode: (node: ts.KeywordTypeNode) => boolean;class JsonTypeError
class JsonTypeError extends BaseError {}constructor
constructor(messageText: string, type: BaseType);property type
readonly type: BaseType;class LiteralNodeParser
class LiteralNodeParser implements SubNodeParser {}constructor
constructor(childNodeParser: NodeParser);property childNodeParser
protected childNodeParser: NodeParser;method createType
createType: (node: ts.LiteralTypeNode, context: Context) => BaseType;method supportsNode
supportsNode: (node: ts.LiteralTypeNode) => boolean;class LiteralType
class LiteralType extends BaseType {}constructor
constructor(value: LiteralValue);method getId
getId: () => string;method getValue
getValue: () => LiteralValue;method isString
isString: () => boolean;class LiteralTypeFormatter
class LiteralTypeFormatter implements SubTypeFormatter {}method getChildren
getChildren: (type: LiteralType) => BaseType[];method getDefinition
getDefinition: (type: LiteralType) => JSONSchema7;method supportsType
supportsType: (type: BaseType) => boolean;class LiteralUnionTypeFormatter
class LiteralUnionTypeFormatter implements SubTypeFormatter {}method getChildren
getChildren: () => BaseType[];method getDefinition
getDefinition: (unionType: UnionType) => JSONSchema7;method supportsType
supportsType: (type: BaseType) => boolean;class LogicError
class LogicError extends BaseError {}constructor
constructor(node: ts.Node, messageText: string);property node
readonly node: ts.Node;class MappedTypeNodeParser
class MappedTypeNodeParser implements SubNodeParser {}constructor
constructor(childNodeParser: NodeParser, additionalProperties: boolean);property additionalProperties
protected readonly additionalProperties: boolean;property childNodeParser
protected childNodeParser: NodeParser;method createSubContext
protected createSubContext: ( node: ts.MappedTypeNode, key: LiteralType | StringType | NumberType, parentContext: Context) => Context;method createType
createType: (node: ts.MappedTypeNode, context: Context) => BaseType;method getAdditionalProperties
protected getAdditionalProperties: ( node: ts.MappedTypeNode, keyListType: UnionType, context: Context) => BaseType | boolean;method getProperties
protected getProperties: ( node: ts.MappedTypeNode, keyListType: UnionType, context: Context) => ObjectProperty[];method getValues
protected getValues: ( node: ts.MappedTypeNode, keyListType: EnumType, context: Context) => ObjectProperty[];method mapKey
protected mapKey: ( node: ts.MappedTypeNode, rawKey: LiteralType, context: Context) => BaseType;method supportsNode
supportsNode: (node: ts.MappedTypeNode) => boolean;class MultipleDefinitionsError
class MultipleDefinitionsError extends BaseError {}constructor
constructor(name: string, defA: BaseType, defB?: BaseType);property defA
readonly defA: BaseType;property defB
readonly defB?: BaseType;property name
readonly name: string;class NeverTypeFormatter
class NeverTypeFormatter implements SubTypeFormatter {}method getChildren
getChildren: (type: NeverType) => BaseType[];method getDefinition
getDefinition: (type: NeverType) => JSONSchema7;method supportsType
supportsType: (type: BaseType) => boolean;class NeverTypeNodeParser
class NeverTypeNodeParser implements SubNodeParser {}method createType
createType: (_node: ts.KeywordTypeNode, _context: Context) => BaseType;method supportsNode
supportsNode: (node: ts.KeywordTypeNode) => boolean;class NullLiteralNodeParser
class NullLiteralNodeParser implements SubNodeParser {}method createType
createType: (node: ts.NullLiteral, context: Context) => BaseType;method supportsNode
supportsNode: (node: ts.NullLiteral) => boolean;class NullTypeFormatter
class NullTypeFormatter implements SubTypeFormatter {}method getChildren
getChildren: (type: NullType) => BaseType[];method getDefinition
getDefinition: (type: NullType) => JSONSchema7;method supportsType
supportsType: (type: BaseType) => boolean;class NumberLiteralNodeParser
class NumberLiteralNodeParser implements SubNodeParser {}method createType
createType: (node: ts.NumericLiteral, context: Context) => BaseType;method supportsNode
supportsNode: (node: ts.NumericLiteral) => boolean;class NumberType
class NumberType extends PrimitiveType {}method getId
getId: () => string;class NumberTypeFormatter
class NumberTypeFormatter implements SubTypeFormatter {}method getChildren
getChildren: (type: NumberType) => BaseType[];method getDefinition
getDefinition: (type: NumberType) => JSONSchema7;method supportsType
supportsType: (type: BaseType) => boolean;class NumberTypeNodeParser
class NumberTypeNodeParser implements SubNodeParser {}method createType
createType: (node: ts.KeywordTypeNode, context: Context) => BaseType;method supportsNode
supportsNode: (node: ts.KeywordTypeNode) => boolean;class ObjectLiteralExpressionNodeParser
class ObjectLiteralExpressionNodeParser implements SubNodeParser {}constructor
constructor(childNodeParser: NodeParser, checker: ts.TypeChecker);property checker
protected checker: ts.TypeChecker;property childNodeParser
protected childNodeParser: NodeParser;method createType
createType: (node: ts.ObjectLiteralExpression, context: Context) => BaseType;method supportsNode
supportsNode: (node: ts.ObjectLiteralExpression) => boolean;class ObjectProperty
class ObjectProperty {}constructor
constructor(name: string, type: BaseType, required: boolean);method getName
getName: () => string;method getType
getType: () => BaseType;method isRequired
isRequired: () => boolean;class ObjectType
class ObjectType extends BaseType {}constructor
constructor( id: string, baseTypes: readonly BaseType[], properties: readonly ObjectProperty[], additionalProperties: boolean | BaseType, nonPrimitive?: boolean);method getAdditionalProperties
getAdditionalProperties: () => BaseType | boolean;method getBaseTypes
getBaseTypes: () => readonly BaseType[];method getId
getId: () => string;method getNonPrimitive
getNonPrimitive: () => boolean;method getProperties
getProperties: () => readonly ObjectProperty[];class ObjectTypeFormatter
class ObjectTypeFormatter implements SubTypeFormatter {}constructor
constructor(childTypeFormatter: TypeFormatter);property childTypeFormatter
protected childTypeFormatter: TypeFormatter;method getChildren
getChildren: (type: ObjectType) => BaseType[];method getDefinition
getDefinition: (type: ObjectType) => JSONSchema7;method getObjectDefinition
protected getObjectDefinition: (type: ObjectType) => JSONSchema7;method prepareObjectProperty
protected prepareObjectProperty: (property: ObjectProperty) => ObjectProperty;method supportsType
supportsType: (type: BaseType) => boolean;class ObjectTypeNodeParser
class ObjectTypeNodeParser implements SubNodeParser {}method createType
createType: (node: ts.KeywordTypeNode, context: Context) => BaseType;method supportsNode
supportsNode: (node: ts.KeywordTypeNode) => boolean;class OptionalType
class OptionalType extends BaseType {}constructor
constructor(item: BaseType);method getId
getId: () => string;method getType
getType: () => BaseType;class OptionalTypeFormatter
class OptionalTypeFormatter implements SubTypeFormatter {}constructor
constructor(childTypeFormatter: TypeFormatter);property childTypeFormatter
protected childTypeFormatter: TypeFormatter;method getChildren
getChildren: (type: OptionalType) => BaseType[];method getDefinition
getDefinition: (type: OptionalType) => JSONSchema7;method supportsType
supportsType: (type: BaseType) => boolean;class OptionalTypeNodeParser
class OptionalTypeNodeParser implements SubNodeParser {}constructor
constructor(childNodeParser: NodeParser);property childNodeParser
protected childNodeParser: NodeParser;method createType
createType: (node: ts.OptionalTypeNode, context: Context) => BaseType;method supportsNode
supportsNode: (node: ts.OptionalTypeNode) => boolean;class ParameterParser
class ParameterParser implements SubNodeParser {}constructor
constructor(childNodeParser: NodeParser);property childNodeParser
protected childNodeParser: NodeParser;method createType
createType: (node: ts.FunctionTypeNode, context: Context) => BaseType;method supportsNode
supportsNode: (node: ts.ParameterDeclaration) => boolean;class ParenthesizedNodeParser
class ParenthesizedNodeParser implements SubNodeParser {}constructor
constructor(childNodeParser: NodeParser);property childNodeParser
protected childNodeParser: NodeParser;method createType
createType: (node: ts.ParenthesizedTypeNode, context: Context) => BaseType;method supportsNode
supportsNode: (node: ts.ParenthesizedTypeNode) => boolean;class PrefixUnaryExpressionNodeParser
class PrefixUnaryExpressionNodeParser implements SubNodeParser {}constructor
constructor(childNodeParser: NodeParser);property childNodeParser
protected childNodeParser: NodeParser;method createType
createType: (node: ts.PrefixUnaryExpression, context: Context) => BaseType;method supportsNode
supportsNode: (node: ts.PrefixUnaryExpression) => boolean;class PrimitiveType
abstract class PrimitiveType extends BaseType {}class PrimitiveUnionTypeFormatter
class PrimitiveUnionTypeFormatter implements SubTypeFormatter {}method getChildren
getChildren: (type: UnionType) => BaseType[];method getDefinition
getDefinition: (type: UnionType) => JSONSchema7;method getPrimitiveType
protected getPrimitiveType: (item: BaseType) => JSONSchema7TypeName;method isPrimitiveUnion
protected isPrimitiveUnion: (type: UnionType) => boolean;method supportsType
supportsType: (type: BaseType) => boolean;class PropertyAccessExpressionParser
class PropertyAccessExpressionParser implements SubNodeParser {}constructor
constructor(typeChecker: ts.TypeChecker, childNodeParser: NodeParser);property childNodeParser
protected childNodeParser: NodeParser;property typeChecker
protected typeChecker: ts.TypeChecker;method createType
createType: (node: ts.PropertyAccessExpression, context: Context) => BaseType;method supportsNode
supportsNode: (node: ts.PropertyAccessExpression) => boolean;class ReferenceType
class ReferenceType extends BaseType {}class ReferenceTypeFormatter
class ReferenceTypeFormatter implements SubTypeFormatter {}constructor
constructor(childTypeFormatter: TypeFormatter, encodeRefs: boolean);property childTypeFormatter
protected childTypeFormatter: TypeFormatter;property encodeRefs
protected encodeRefs: boolean;method getChildren
getChildren: (type: ReferenceType) => BaseType[];method getDefinition
getDefinition: (type: ReferenceType) => JSONSchema7;method supportsType
supportsType: (type: BaseType) => boolean;class RestType
class RestType extends BaseType {}constructor
constructor(item: ArrayType | InferType | TupleType, title?: string);method getId
getId: () => string;method getTitle
getTitle: () => string | null;method getType
getType: () => ArrayType | InferType | TupleType;class RestTypeFormatter
class RestTypeFormatter implements SubTypeFormatter {}constructor
constructor(childTypeFormatter: TypeFormatter);property childTypeFormatter
protected childTypeFormatter: TypeFormatter;method getChildren
getChildren: (type: RestType) => BaseType[];method getDefinition
getDefinition: (type: RestType) => JSONSchema7;method supportsType
supportsType: (type: BaseType) => boolean;class RestTypeNodeParser
class RestTypeNodeParser implements SubNodeParser {}constructor
constructor(childNodeParser: NodeParser);property childNodeParser
protected childNodeParser: NodeParser;method createType
createType: (node: ts.RestTypeNode, context: Context) => BaseType;method supportsNode
supportsNode: (node: ts.RestTypeNode) => boolean;class RootlessError
class RootlessError extends BaseError {}constructor
constructor(fullName: string);property fullName
readonly fullName: string;class SchemaGenerator
class SchemaGenerator {}constructor
constructor( program: ts.Program, nodeParser: NodeParser, typeFormatter: TypeFormatter, config?: Config);property config
protected readonly config?: Config;property nodeParser
protected readonly nodeParser: NodeParser;property program
protected readonly program: ts.Program;property typeFormatter
protected readonly typeFormatter: TypeFormatter;method appendRootChildDefinitions
protected appendRootChildDefinitions: ( rootType: BaseType, childDefinitions: StringMap<Definition>) => void;method appendTypes
protected appendTypes: ( sourceFiles: readonly ts.SourceFile[], typeChecker: ts.TypeChecker, types: Map<string, ts.Node>) => void;method createSchema
createSchema: (fullNames?: string | string[]) => JSONSchema7;method createSchemaFromNodes
createSchemaFromNodes: (rootNodes: ts.Node[]) => JSONSchema7;method findNamedNode
protected findNamedNode: (fullName: string) => ts.Node;method getFullName
protected getFullName: ( node: ts.Declaration, typeChecker: ts.TypeChecker) => string;method getRootNodes
protected getRootNodes: (fullNames: string[] | undefined) => ts.Node[];method getRootTypeDefinition
protected getRootTypeDefinition: ( rootType: BaseType, rootNode: ts.Node) => JSONSchema7;method inspectNode
protected inspectNode: ( node: ts.Node, typeChecker: ts.TypeChecker, allTypes: Map<string, ts.Node>) => void;method isExportType
protected isExportType: ( node: | ts.InterfaceDeclaration | ts.ClassDeclaration | ts.EnumDeclaration | ts.TypeAliasDeclaration) => boolean;method isGenericType
protected isGenericType: (node: ts.TypeAliasDeclaration) => boolean;method partitionFiles
protected partitionFiles: () => { projectFiles: ts.SourceFile[]; externalFiles: ts.SourceFile[];};class StringLiteralNodeParser
class StringLiteralNodeParser implements SubNodeParser {}method createType
createType: (node: ts.StringLiteral, context: Context) => BaseType;method supportsNode
supportsNode: (node: ts.StringLiteral) => boolean;class StringTemplateLiteralNodeParser
class StringTemplateLiteralNodeParser implements SubNodeParser {}constructor
constructor(childNodeParser: NodeParser);property childNodeParser
protected childNodeParser: NodeParser;method createType
createType: ( node: ts.NoSubstitutionTemplateLiteral | ts.TemplateLiteralTypeNode, context: Context) => BaseType;method supportsNode
supportsNode: ( node: ts.NoSubstitutionTemplateLiteral | ts.TemplateLiteralTypeNode) => boolean;class StringType
class StringType extends PrimitiveType {}constructor
constructor(preserveLiterals?: boolean);property preserveLiterals
protected preserveLiterals: boolean;method getId
getId: () => string;method getPreserveLiterals
getPreserveLiterals: () => boolean;class StringTypeFormatter
class StringTypeFormatter implements SubTypeFormatter {}method getChildren
getChildren: (type: StringType) => BaseType[];method getDefinition
getDefinition: (type: StringType) => JSONSchema7;method supportsType
supportsType: (type: BaseType) => boolean;class StringTypeNodeParser
class StringTypeNodeParser implements SubNodeParser {}method createType
createType: (node: ts.KeywordTypeNode, context: Context) => BaseType;method supportsNode
supportsNode: (node: ts.KeywordTypeNode) => boolean;class SymbolType
class SymbolType extends PrimitiveType {}method getId
getId: () => string;class SymbolTypeFormatter
class SymbolTypeFormatter implements SubTypeFormatter {}method getChildren
getChildren: (type: SymbolType) => BaseType[];method getDefinition
getDefinition: (type: SymbolType) => JSONSchema7;method supportsType
supportsType: (type: BaseType) => boolean;class SymbolTypeNodeParser
class SymbolTypeNodeParser implements SubNodeParser {}method createType
createType: (node: ts.KeywordTypeNode, context: Context) => BaseType;method supportsNode
supportsNode: (node: ts.KeywordTypeNode) => boolean;class TopRefNodeParser
class TopRefNodeParser implements NodeParser {}constructor
constructor(childNodeParser: NodeParser, fullName: string, topRef: boolean);property childNodeParser
protected childNodeParser: NodeParser;property fullName
protected fullName: string;property topRef
protected topRef: boolean;method createType
createType: (node: ts.Node, context: Context) => BaseType;class TupleNodeParser
class TupleNodeParser implements SubNodeParser {}constructor
constructor(typeChecker: ts.TypeChecker, childNodeParser: NodeParser);property childNodeParser
protected childNodeParser: NodeParser;property typeChecker
protected typeChecker: ts.TypeChecker;method createType
createType: (node: ts.TupleTypeNode, context: Context) => BaseType;method supportsNode
supportsNode: (node: ts.TupleTypeNode) => boolean;class TupleType
class TupleType extends BaseType {}constructor
constructor(types: readonly BaseType[]);method getId
getId: () => string;method getTypes
getTypes: () => Readonly<Array<BaseType>>;class TupleTypeFormatter
class TupleTypeFormatter implements SubTypeFormatter {}constructor
constructor(childTypeFormatter: TypeFormatter);property childTypeFormatter
protected childTypeFormatter: TypeFormatter;method getChildren
getChildren: (type: TupleType) => BaseType[];method getDefinition
getDefinition: (type: TupleType) => JSONSchema7;method supportsType
supportsType: (type: BaseType) => boolean;class TypeAliasNodeParser
class TypeAliasNodeParser implements SubNodeParser {}constructor
constructor(typeChecker: ts.TypeChecker, childNodeParser: NodeParser);property childNodeParser
protected childNodeParser: NodeParser;property typeChecker
protected typeChecker: ts.TypeChecker;method createType
createType: ( node: ts.TypeAliasDeclaration, context: Context, reference?: ReferenceType) => BaseType;method getTypeId
protected getTypeId: (node: ts.TypeAliasDeclaration, context: Context) => string;method getTypeName
protected getTypeName: ( node: ts.TypeAliasDeclaration, context: Context) => string;method supportsNode
supportsNode: (node: ts.TypeAliasDeclaration) => boolean;class TypeLiteralNodeParser
class TypeLiteralNodeParser implements SubNodeParser {}constructor
constructor( typeChecker: ts.TypeChecker, childNodeParser: NodeParser, additionalProperties: boolean);property additionalProperties
protected readonly additionalProperties: boolean;property childNodeParser
protected childNodeParser: NodeParser;property typeChecker
protected typeChecker: ts.TypeChecker;method createType
createType: ( node: ts.TypeLiteralNode, context: Context, reference?: ReferenceType) => BaseType;method getAdditionalProperties
protected getAdditionalProperties: ( node: ts.TypeLiteralNode, context: Context) => BaseType | boolean;method getProperties
protected getProperties: ( node: ts.TypeLiteralNode, context: Context) => ObjectProperty[] | undefined;method getPropertyName
protected getPropertyName: (propertyName: ts.PropertyName) => string;method getTypeId
protected getTypeId: (node: ts.Node, context: Context) => string;method supportsNode
supportsNode: (node: ts.TypeLiteralNode) => boolean;class TypeofNodeParser
class TypeofNodeParser implements SubNodeParser {}constructor
constructor(typeChecker: ts.TypeChecker, childNodeParser: NodeParser);property childNodeParser
protected childNodeParser: NodeParser;property typeChecker
protected typeChecker: ts.TypeChecker;method createObjectFromEnum
protected createObjectFromEnum: ( node: ts.EnumDeclaration, context: Context, reference?: ReferenceType) => ObjectType;method createType
createType: ( node: ts.TypeQueryNode, context: Context, reference?: ReferenceType) => BaseType;method supportsNode
supportsNode: (node: ts.TypeQueryNode) => boolean;class TypeOperatorNodeParser
class TypeOperatorNodeParser implements SubNodeParser {}constructor
constructor(childNodeParser: NodeParser);property childNodeParser
protected childNodeParser: NodeParser;method createType
createType: (node: ts.TypeOperatorNode, context: Context) => BaseType;method supportsNode
supportsNode: (node: ts.TypeOperatorNode) => boolean;class TypeReferenceNodeParser
class TypeReferenceNodeParser implements SubNodeParser {}constructor
constructor(typeChecker: ts.TypeChecker, childNodeParser: NodeParser);property childNodeParser
protected childNodeParser: NodeParser;property typeChecker
protected typeChecker: ts.TypeChecker;method createSubContext
protected createSubContext: ( node: ts.TypeReferenceNode, parentContext: Context) => Context;method createType
createType: (node: ts.TypeReferenceNode, context: Context) => BaseType;method supportsNode
supportsNode: (node: ts.TypeReferenceNode) => boolean;class UndefinedLiteralNodeParser
class UndefinedLiteralNodeParser implements SubNodeParser {}method createType
createType: (node: ts.KeywordTypeNode, context: Context) => BaseType;method supportsNode
supportsNode: (node: ts.KeywordTypeNode) => boolean;class UndefinedType
class UndefinedType extends BaseType {}method getId
getId: () => string;class UndefinedTypeFormatter
class UndefinedTypeFormatter implements SubTypeFormatter {}method getChildren
getChildren: (type: UndefinedType) => BaseType[];method getDefinition
getDefinition: (type: UndefinedType) => JSONSchema7;method supportsType
supportsType: (type: BaseType) => boolean;class UndefinedTypeNodeParser
class UndefinedTypeNodeParser implements SubNodeParser {}method createType
createType: (node: ts.KeywordTypeNode, context: Context) => BaseType;method supportsNode
supportsNode: (node: ts.KeywordTypeNode) => boolean;class UnhandledError
class UnhandledError extends BaseError {}class UnionNodeParser
class UnionNodeParser implements SubNodeParser {}constructor
constructor(typeChecker: ts.TypeChecker, childNodeParser: NodeParser);property childNodeParser
protected childNodeParser: NodeParser;property typeChecker
protected typeChecker: ts.TypeChecker;method createType
createType: (node: ts.UnionTypeNode, context: Context) => BaseType;method supportsNode
supportsNode: (node: ts.UnionTypeNode) => boolean;class UnionType
class UnionType extends BaseType {}constructor
constructor(types: readonly BaseType[]);method getDiscriminator
getDiscriminator: () => string | undefined;method getFlattenedTypes
getFlattenedTypes: (deref?: (type: BaseType) => BaseType) => BaseType[];Get the types in this union as a flat list.
method getId
getId: () => string;method getName
getName: () => string;method getTypes
getTypes: () => BaseType[];method normalize
normalize: () => BaseType;method setDiscriminator
setDiscriminator: (discriminator: string) => void;class UnionTypeFormatter
class UnionTypeFormatter implements SubTypeFormatter {}constructor
constructor( childTypeFormatter: TypeFormatter, discriminatorType?: DiscriminatorType);property childTypeFormatter
protected childTypeFormatter: TypeFormatter;method getChildren
getChildren: (type: UnionType) => BaseType[];method getDefinition
getDefinition: (type: UnionType) => JSONSchema7;method supportsType
supportsType: (type: BaseType) => boolean;class UnknownNodeError
class UnknownNodeError extends BaseError {}constructor
constructor(node: ts.Node);property node
readonly node: ts.Node;class UnknownType
class UnknownType extends BaseType {}constructor
constructor(erroredSource?: boolean);property erroredSource
readonly erroredSource: boolean;If the source for this UnknownType was from a failed operation than to an actual
unknowntype present in the source code.
method getId
getId: () => string;class UnknownTypeError
class UnknownTypeError extends BaseError {}constructor
constructor(type: BaseType);property type
readonly type: BaseType;class UnknownTypeFormatter
class UnknownTypeFormatter implements SubTypeFormatter {}method getChildren
getChildren: () => BaseType[];method getDefinition
getDefinition: (type: UnknownType) => JSONSchema7;method supportsType
supportsType: (type: BaseType) => boolean;class UnknownTypeNodeParser
class UnknownTypeNodeParser implements SubNodeParser {}method createType
createType: () => BaseType;method supportsNode
supportsNode: (node: ts.KeywordTypeNode) => boolean;class VoidTypeFormatter
class VoidTypeFormatter implements SubTypeFormatter {}method getChildren
getChildren: (type: VoidType) => BaseType[];method getDefinition
getDefinition: (type: VoidType) => JSONSchema7;method supportsType
supportsType: (type: BaseType) => boolean;class VoidTypeNodeParser
class VoidTypeNodeParser implements SubNodeParser {}method createType
createType: (node: ts.KeywordTypeNode, context: Context) => BaseType;method supportsNode
supportsNode: (node: ts.KeywordTypeNode) => boolean;Interfaces
interface AnnotationsReader
interface AnnotationsReader {}method getAnnotations
getAnnotations: (node: ts.Node) => Annotations | undefined;interface Config
interface Config {}property additionalProperties
additionalProperties?: boolean;Sets default value for
additionalPropertieson objects without index signatures. When false, objects getadditionalProperties: falseby default. When true, allows additional properties on all objects. false
property discriminatorType
discriminatorType?: 'json-schema' | 'open-api';Controls discriminator style for discriminated unions. - "json-schema": Uses
if/then/allOfwith properties containing discriminator enum - "open-api": Uses OpenAPI 3.x style withdiscriminator: { propertyName }andoneOf"json-schema"
property encodeRefs
encodeRefs?: boolean;URI-encodes
$refvalues (e.g.,#/definitions/Foo%3CBar%3E). When false, uses raw names in reference paths. true
property extraTags
extraTags?: string[];Array of additional JSDoc tag names to include in the schema. Custom tags (e.g.,
@customProperty) are parsed and included in output. Values are parsed as JSON5. []
property fullDescription
fullDescription?: boolean;Includes the complete raw JSDoc comment as
fullDescriptionin the schema. Only works withjsDoc: "extended". false
property functions
functions?: FunctionOptions;Controls how function types are handled in the schema. - "fail": Throws error when encountering function types - "comment": Generates schema with
$commentdescribing the function signature - "hide": Treats functions as NeverType (excluded from schema) "comment"
property jsDoc
jsDoc?: 'none' | 'extended' | 'basic';Controls how JSDoc comments are parsed and included in the schema. - "none": Ignores all JSDoc annotations - "basic": Parses standard JSON Schema JSDoc tags - "extended": Parses all tags plus descriptions, examples, and type overrides "extended"
property markdownDescription
markdownDescription?: boolean;Adds a
markdownDescriptionfield alongsidedescriptionin the schema. Preserves markdown formatting including newlines. Only works withjsDoc: "extended". false
property minify
minify?: boolean;Minify the output JSON schema (no whitespace). When false, the schema is pretty-printed with 2-space indentation. false
property path
path?: string;Glob pattern(s) for source TypeScript files to process. If not provided, falls back to files from tsconfig.
property schemaId
schemaId?: string;Sets the
$idproperty in the root of the generated schema. Used for schema identification and referencing.
property skipTypeCheck
skipTypeCheck?: boolean;Skips TypeScript type checking to improve performance. Speeds up generation but may miss type errors. false
property sortProps
sortProps?: boolean;Sorts object properties alphabetically in the output. true
property strictTuples
strictTuples?: boolean;Controls whether tuples allow additional items beyond their defined length. false
property topRef
topRef?: boolean;Wraps the root type in a
$refdefinition. When false, inlines the root type definition directly. true
property tsconfig
tsconfig?: string;Path to a custom tsconfig.json file for TypeScript compilation. If not provided, uses default TypeScript configuration.
property tsProgram
tsProgram?: ts.Program;Pre-compiled TypeScript Program instance to use. Bypasses the default setup of a TypeScript program, and so some configuration options may not be applied. Useful for programmatic usage with existing TypeScript compilation, or for vfs scenarios where you do not want file-system representation.
property type
type?: string | string[];Name of the type(s)/interface(s) to generate schema for. Use "*" to generate schemas for all exported types.
interface MutableParser
interface MutableParser {}method addNodeParser
addNodeParser: (parser: SubNodeParser) => MutableParser;interface MutableTypeFormatter
interface MutableTypeFormatter {}method addTypeFormatter
addTypeFormatter: (formatter: SubTypeFormatter) => MutableTypeFormatter;interface NodeParser
interface NodeParser {}method createType
createType: ( node: ts.Node, context: Context, reference?: ReferenceType) => BaseType;interface StringMap
interface StringMap<T> {}index signature
[key: string]: T;interface SubNodeParser
interface SubNodeParser extends NodeParser {}method supportsNode
supportsNode: (node: ts.Node) => boolean;interface SubTypeFormatter
interface SubTypeFormatter extends TypeFormatter {}method supportsType
supportsType: (type: BaseType) => boolean;interface TypeFormatter
interface TypeFormatter {}method getChildren
getChildren: (type: BaseType) => BaseType[];method getDefinition
getDefinition: (type: BaseType) => JSONSchema7;Type Aliases
type Annotations
type Annotations = Record<string, unknown>;type CompletedConfig
type CompletedConfig = Config & typeof DEFAULT_CONFIG;type Definition
type Definition = JSONSchema7;type EnumValue
type EnumValue = string | boolean | number | null;type FormatterAugmentor
type FormatterAugmentor = ( formatter: MutableTypeFormatter, circularReferenceTypeFormatter: CircularReferenceTypeFormatter) => void;type FunctionOptions
type FunctionOptions = 'fail' | 'comment' | 'hide';type LiteralValue
type LiteralValue = string | number | boolean;type ParserAugmentor
type ParserAugmentor = (parser: MutableParser) => void;type PartialDiagnostic
type PartialDiagnostic = Omit< ts.Diagnostic, 'category' | 'file' | 'start' | 'length'> & { file?: ts.SourceFile; start?: number; length?: number; /** If we should populate `file`, `source`, `start` and `length` with this node information */ node?: ts.Node; /** @default Error */ category?: ts.DiagnosticCategory;};type Schema
type Schema = JSONSchema7;Package Files (149)
- dist/factory/formatter.d.ts
- dist/factory/generator.d.ts
- dist/factory/parser.d.ts
- dist/factory/program.d.ts
- dist/index.d.ts
- dist/src/AnnotationsReader/BasicAnnotationsReader.d.ts
- dist/src/AnnotationsReader/ExtendedAnnotationsReader.d.ts
- dist/src/ChainNodeParser.d.ts
- dist/src/ChainTypeFormatter.d.ts
- dist/src/CircularReferenceNodeParser.d.ts
- dist/src/CircularReferenceTypeFormatter.d.ts
- dist/src/Config.d.ts
- dist/src/Error/BaseError.d.ts
- dist/src/Error/Errors.d.ts
- dist/src/ExposeNodeParser.d.ts
- dist/src/Interfaces/AnnotationsReader.d.ts
- dist/src/Interfaces/MutableParser.d.ts
- dist/src/MutableTypeFormatter.d.ts
- dist/src/NodeParser.d.ts
- dist/src/NodeParser/AnnotatedNodeParser.d.ts
- dist/src/NodeParser/AnyTypeNodeParser.d.ts
- dist/src/NodeParser/ArrayLiteralExpressionNodeParser.d.ts
- dist/src/NodeParser/ArrayNodeParser.d.ts
- dist/src/NodeParser/AsExpressionNodeParser.d.ts
- dist/src/NodeParser/BooleanLiteralNodeParser.d.ts
- dist/src/NodeParser/BooleanTypeNodeParser.d.ts
- dist/src/NodeParser/CallExpressionParser.d.ts
- dist/src/NodeParser/ConditionalTypeNodeParser.d.ts
- dist/src/NodeParser/ConstructorNodeParser.d.ts
- dist/src/NodeParser/EnumNodeParser.d.ts
- dist/src/NodeParser/ExpressionWithTypeArgumentsNodeParser.d.ts
- dist/src/NodeParser/FunctionNodeParser.d.ts
- dist/src/NodeParser/HiddenTypeNodeParser.d.ts
- dist/src/NodeParser/IndexedAccessTypeNodeParser.d.ts
- dist/src/NodeParser/InterfaceAndClassNodeParser.d.ts
- dist/src/NodeParser/IntersectionNodeParser.d.ts
- dist/src/NodeParser/IntrinsicNodeParser.d.ts
- dist/src/NodeParser/LiteralNodeParser.d.ts
- dist/src/NodeParser/MappedTypeNodeParser.d.ts
- dist/src/NodeParser/NeverTypeNodeParser.d.ts
- dist/src/NodeParser/NullLiteralNodeParser.d.ts
- dist/src/NodeParser/NumberLiteralNodeParser.d.ts
- dist/src/NodeParser/NumberTypeNodeParser.d.ts
- dist/src/NodeParser/ObjectLiteralExpressionNodeParser.d.ts
- dist/src/NodeParser/ObjectTypeNodeParser.d.ts
- dist/src/NodeParser/OptionalTypeNodeParser.d.ts
- dist/src/NodeParser/ParameterParser.d.ts
- dist/src/NodeParser/ParenthesizedNodeParser.d.ts
- dist/src/NodeParser/PrefixUnaryExpressionNodeParser.d.ts
- dist/src/NodeParser/PropertyAccessExpressionParser.d.ts
- dist/src/NodeParser/RestTypeNodeParser.d.ts
- dist/src/NodeParser/StringLiteralNodeParser.d.ts
- dist/src/NodeParser/StringTemplateLiteralNodeParser.d.ts
- dist/src/NodeParser/StringTypeNodeParser.d.ts
- dist/src/NodeParser/SymbolTypeNodeParser.d.ts
- dist/src/NodeParser/TupleNodeParser.d.ts
- dist/src/NodeParser/TypeAliasNodeParser.d.ts
- dist/src/NodeParser/TypeLiteralNodeParser.d.ts
- dist/src/NodeParser/TypeOperatorNodeParser.d.ts
- dist/src/NodeParser/TypeReferenceNodeParser.d.ts
- dist/src/NodeParser/TypeofNodeParser.d.ts
- dist/src/NodeParser/UndefinedLiteralNodeParser.d.ts
- dist/src/NodeParser/UndefinedTypeNodeParser.d.ts
- dist/src/NodeParser/UnionNodeParser.d.ts
- dist/src/NodeParser/UnknownTypeNodeParser.d.ts
- dist/src/NodeParser/VoidTypeNodeParser.d.ts
- dist/src/Schema/Definition.d.ts
- dist/src/Schema/Schema.d.ts
- dist/src/SchemaGenerator.d.ts
- dist/src/SubNodeParser.d.ts
- dist/src/SubTypeFormatter.d.ts
- dist/src/TopRefNodeParser.d.ts
- dist/src/Type/AliasType.d.ts
- dist/src/Type/AnnotatedType.d.ts
- dist/src/Type/AnyType.d.ts
- dist/src/Type/ArrayType.d.ts
- dist/src/Type/BaseType.d.ts
- dist/src/Type/BooleanType.d.ts
- dist/src/Type/DefinitionType.d.ts
- dist/src/Type/EnumType.d.ts
- dist/src/Type/FunctionType.d.ts
- dist/src/Type/HiddenType.d.ts
- dist/src/Type/IntersectionType.d.ts
- dist/src/Type/LiteralType.d.ts
- dist/src/Type/NeverType.d.ts
- dist/src/Type/NullType.d.ts
- dist/src/Type/NumberType.d.ts
- dist/src/Type/ObjectType.d.ts
- dist/src/Type/OptionalType.d.ts
- dist/src/Type/PrimitiveType.d.ts
- dist/src/Type/ReferenceType.d.ts
- dist/src/Type/RestType.d.ts
- dist/src/Type/StringType.d.ts
- dist/src/Type/SymbolType.d.ts
- dist/src/Type/TupleType.d.ts
- dist/src/Type/UndefinedType.d.ts
- dist/src/Type/UnionType.d.ts
- dist/src/Type/UnknownType.d.ts
- dist/src/Type/VoidType.d.ts
- dist/src/TypeFormatter.d.ts
- dist/src/TypeFormatter/AliasTypeFormatter.d.ts
- dist/src/TypeFormatter/AnnotatedTypeFormatter.d.ts
- dist/src/TypeFormatter/AnyTypeFormatter.d.ts
- dist/src/TypeFormatter/ArrayTypeFormatter.d.ts
- dist/src/TypeFormatter/BooleanTypeFormatter.d.ts
- dist/src/TypeFormatter/DefinitionTypeFormatter.d.ts
- dist/src/TypeFormatter/EnumTypeFormatter.d.ts
- dist/src/TypeFormatter/FunctionTypeFormatter.d.ts
- dist/src/TypeFormatter/HiddenTypeFormatter.d.ts
- dist/src/TypeFormatter/IntersectionTypeFormatter.d.ts
- dist/src/TypeFormatter/LiteralTypeFormatter.d.ts
- dist/src/TypeFormatter/LiteralUnionTypeFormatter.d.ts
- dist/src/TypeFormatter/NeverTypeFormatter.d.ts
- dist/src/TypeFormatter/NullTypeFormatter.d.ts
- dist/src/TypeFormatter/NumberTypeFormatter.d.ts
- dist/src/TypeFormatter/ObjectTypeFormatter.d.ts
- dist/src/TypeFormatter/OptionalTypeFormatter.d.ts
- dist/src/TypeFormatter/PrimitiveUnionTypeFormatter.d.ts
- dist/src/TypeFormatter/ReferenceTypeFormatter.d.ts
- dist/src/TypeFormatter/RestTypeFormatter.d.ts
- dist/src/TypeFormatter/StringTypeFormatter.d.ts
- dist/src/TypeFormatter/SymbolTypeFormatter.d.ts
- dist/src/TypeFormatter/TupleTypeFormatter.d.ts
- dist/src/TypeFormatter/UndefinedTypeFormatter.d.ts
- dist/src/TypeFormatter/UnionTypeFormatter.d.ts
- dist/src/TypeFormatter/UnknownTypeFormatter.d.ts
- dist/src/TypeFormatter/VoidTypeFormatter.d.ts
- dist/src/Utils/String.d.ts
- dist/src/Utils/StringMap.d.ts
- dist/src/Utils/allOfDefinition.d.ts
- dist/src/Utils/deepMerge.d.ts
- dist/src/Utils/derefType.d.ts
- dist/src/Utils/extractLiterals.d.ts
- dist/src/Utils/hasJsDocTag.d.ts
- dist/src/Utils/intersectionOfArrays.d.ts
- dist/src/Utils/isAssignableTo.d.ts
- dist/src/Utils/isHidden.d.ts
- dist/src/Utils/modifiers.d.ts
- dist/src/Utils/narrowType.d.ts
- dist/src/Utils/nodeKey.d.ts
- dist/src/Utils/notNever.d.ts
- dist/src/Utils/preserveAnnotation.d.ts
- dist/src/Utils/removeUndefined.d.ts
- dist/src/Utils/removeUnreachable.d.ts
- dist/src/Utils/symbolAtNode.d.ts
- dist/src/Utils/typeKeys.d.ts
- dist/src/Utils/typeName.d.ts
- dist/src/Utils/uniqueArray.d.ts
- dist/src/Utils/uniqueTypeArray.d.ts
Dependencies (7)
Dev Dependencies (22)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto 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/ts-json-schema-generator.
- Markdown[](https://www.jsdocs.io/package/ts-json-schema-generator)
- HTML<a href="https://www.jsdocs.io/package/ts-json-schema-generator"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 10259 ms. - Missing or incorrect documentation? Open an issue for this package.
