Fork me on GitHub

typescript-generator:generate

Full name:

cz.habarta.typescript-generator:typescript-generator-maven-plugin:2.29.820:generate

Description:

Generates TypeScript declaration file from specified java classes. For more information see README and Wiki on GitHub.

Attributes:

  • Requires a Maven project to be executed.
  • Requires dependency resolution of artifacts in scope: compile.
  • Binds by default to the lifecycle phase: process-classes.

Required Parameters

Name Type Since Description
<jsonLibrary> JsonLibrary - Library used in JSON classes. Supported values are:
  • jackson1 - annotations from `org.codehaus.jackson.annotate` package
  • jackson2 - annotations from `com.fasterxml.jackson.annotation` package
  • jaxb - annotations from `javax.xml.bind.annotation` package
  • gson - annotations from `com.google.gson.annotations` package
  • jsonb - annotations from `javax.json.bind.annotation` package
Required parameter, recommended value is jackson2.
<outputKind> TypeScriptOutputKind - Kind of generated TypeScript output. Allowed values are:
  • global - means that declarations will be in global scope or namespace (no module)
  • module - means that generated file will contain top-level export declarations
  • ambientModule - means that generated declarations will be wrapped in declare module "mod" { } declaration
Required parameter. For more information see Modules and Namespaces Wiki page.

Optional Parameters

Name Type Since Description
<addTypeNamePrefix> String - Prefix which will be added to names of classes, interfaces, enums. For example if set to I then mapping for Data will be IData.
<addTypeNameSuffix> String - Suffix which will be added to names of classes, interfaces, enums. For example if set to Data then mapping for Person will be PersonData.
<additionalDataLibraries> List - Allows to add support for specified libraries. Some libraries have special Jackson serializers and deserializers for their data types so this parameter allows to reflect actual JSON format of those data types. Note: specified library must be present in project dependencies (typescript-generator itself doesn't depend on those libraries). Supported libraries are:
<classPatterns> List - Classes to process specified using glob patterns so it is possible to specify package or class name suffix. Glob patterns support two wildcards:
  • Single * wildcard matches any character except for . and $.
  • Double ** wildcard matches any character.
For more information and examples see Class Names Glob Patterns Wiki page.
<classes> List - Classes to process.
<classesExtendingClasses> List - Classes to process specified by extended superclasses.
<classesFromAutomaticJaxrsApplication> boolean - Scans JAX-RS resources for JSON classes to process. It is possible to exclude particular REST resource classes using excludeClasses parameter.
<classesFromJaxrsApplication> String - Scans specified JAX-RS Application for classes to process. Parameter contains fully-qualified class name. It is possible to exclude particular REST resource classes using excludeClasses parameter.
<classesImplementingInterfaces> List - Classes to process specified by implemented interface.
<classesWithAnnotations> List - Classes to process specified by annotations.
<customTypeAliases> List - List of custom type aliases. Each item it this list specifies type alias name (possibly with generic parameters) and its definition. Item format is: name:definition. For example for Unwrap<T>:T following type alias will be generated type Unwrap<T> = T. Other examples: SimpleName:VeryLongGeneratedName, StringID<T>:string.
<customTypeMappings> List - List of custom mappings. Each item specifies TypeScript type which will be used for particular Java class. Item format is: javaClassName:typescriptType. For example mapping Joda-Time LocalDateTime to string would be added as org.joda.time.LocalDateTime:string. Mappings of generic classes must use syntax com.package.MyGenericClass<T1,T2>:TsGenericType2<T1,T2>. Instead of <T1,T2> it is also possible to use [T1,T2].
<customTypeNaming> List - Specifies custom TypeScript names for Java classes. Multiple mappings can be specified, each using this format: javaClassName:typescriptName. This takes precedence over other naming settings. For more information and example see Type Mapping Wiki page.
<customTypeNamingFunction> String - Specifies JavaScript function for getting custom TypeScript names for Java classes. Function can return undefined if default name should be used.
Function signature: function getName(className: string, classSimpleName: string): string | null | undefined;
Example function: function(name, simpleName) { if (name.startsWith('cz.')) return 'Test' + simpleName; }
<customTypeProcessor> String - Specifies custom class implementing TypeProcessor. This allows to customize how Java types are mapped to TypeScript. For example it is possible to implement TypeProcessor for Optional from guava.
<debug> boolean - Deprecated, use loggingLevel parameter.
<declarePropertiesAsOptional> boolean - Deprecated, use optionalProperties parameter.
<declarePropertiesAsReadOnly> boolean - If true declared properties will be readonly.
<disableJackson2ModuleDiscovery> boolean - Deprecated, see jackson2ModuleDiscovery and jackson2Modules parameters.
<disableTaggedUnionAnnotations> List - Specifies annotations used for disabling tagged union created from classes. In case of Jackson2 library this means class hierarchy formed using @JsonTypeInfo and @JsonSubTypes annotations. While disableTaggedUnions parameter only disables creation of TypeScript discriminated union types this parameter allows to disable also processing of discriminant property.
<disableTaggedUnions> boolean - If true tagged unions will not be generated for Jackson 2 polymorphic types. This parameter does not disable processing of discriminant property. See also disableTaggedUnionAnnotations parameter.
<displaySerializerWarning> boolean - Deprecated.
<enumMemberCasing> IdentifierCasing - Specifies how enum members will be named. Supported values are:
  • keepOriginal - keeps member name as is
  • PascalCase - converts name to Pascal case (upper camel case) convention
  • camelCase - converts name to lower camel case convention
Default value is keepOriginal.
<excludeClassPatterns> List - Excluded classes specified using glob patterns. For more information and examples see Class Names Glob Patterns Wiki page.
<excludeClasses> List - List of classes excluded from processing.
<excludePropertyAnnotations> List - Properties with any of these annotations will be excluded.
<extensions> List - List of extensions specified as fully qualified class name. Known extensions:
  • cz.habarta.typescript.generator.ext.AxiosClientExtension} - generates client for JAX-RS service using Axios library, see JAX RS ApplicationWiki page
  • cz.habarta.typescript.generator.ext.BeanPropertyPathExtension} - generates type-safe property path getters
  • cz.habarta.typescript.generator.ext.TypeGuardsForJackson2PolymorphismExtension}
Parameter extensionsWithConfiguration can be used in case extension needs some configuration.
<extensionsWithConfiguration> List - List of extensions with their configurations. This parameter has the same purpose as extensions parameter. Each item of this list has
  • className - required fully-qualified class name of the extension
  • configuration - optional Map with String keys and String values

<generateConstructors> boolean - If true generated classes will also have constructors. Generated constructors use "named parameters" pattern so when calling such constructor parameters need to be wrapped in "options" object. This parameter can only be used when mapClasses parameter is set to asClasses value.
<generateInfoJson> boolean - If true JSON file describing generated module will be generated. In following typescript-generator run this allows to generate another module which could depend on currently generated module. Generated JSON file contains mapping from Java classes to TypeScript types which typescript-generator needs when the module is referenced from another module using moduleDependencies parameter. Only applicable when outputKind is set to module.
<generateJaxrsApplicationClient> boolean - If true client for JAX-RS REST application will be generated.
<generateJaxrsApplicationInterface> boolean - If true interface for JAX-RS REST application will be generated.
<generateNpmPackageJson> boolean - If true NPM package.json will be generated. Only applicable when outputKind is set to module. NPM package name and version can be specified using npmName and npmVersion parameters.
<generateReadonlyAndWriteonlyJSDocTags> boolean - If true JSDoc tags @readonly and @writeonly will be generated on properties with read-only or write-only access.
<generateSpringApplicationClient> boolean - If true client for Spring REST application will be generated.
<generateSpringApplicationInterface> boolean - If true interface for Spring REST application will be generated.
<gsonConfiguration> GsonConfiguration - Specifies Gson global configuration. Description of individual parameters is in GsonConfiguration class on GitHub (latest version).
<ignoreSwaggerAnnotations> boolean - If true Swagger annotations will not be used.
<importDeclarations> List - List of import declarations which will be added to generated output. This can be used with customTypeMappings to provide needed TypeScript types.
<includePropertyAnnotations> List - If this list is not empty then only properties with any of these annotations will be included.
<indentString> String - Specifies indentation string. In Maven pom.xml file it is needed to set xml:space attribute to preserve.
Example: <indentString xml:space="preserve"> </indentString>.
<jackson2Configuration> Jackson2Configuration - Specifies Jackson 2 global configuration. Description of individual parameters is in Jackson2Configuration class on GitHub (latest version).
<jackson2ModuleDiscovery> boolean - Turns on Jackson2 automatic module discovery.
<jackson2Modules> List - Specifies Jackson2 modules to use.
<javadocXmlFiles> List - List of Javadoc XML files to search for documentation comments. These files should be created using com.github.markusbernhardt.xmldoclet.XmlDoclet from com.github.markusbernhardt:xml-doclet artifact. Javadoc comments are added to output declarations as JSDoc comments. For more information see Javadoc Wiki page.
<jaxrsNamespacing> RestNamespacing - Deprecated, use restNamespacing.
<jaxrsNamespacingAnnotation> String - Deprecated, use restNamespacingAnnotation.
<jsonbConfiguration> JsonbConfiguration - Specifies JSON-B global configuration. Description of individual parameters is in Jackson2Configuration class on GitHub (latest version).
<loggingLevel> Logger$Level - Specifies level of logging output. Supported values are:
  • Debug
  • Verbose
  • Info
  • Warning
  • Error
Default value is Verbose.
<mapClasses> ClassMapping - Specifies whether Java classes will be mapped to TypeScript classes or interfaces. Java interfaces are always mapped as TypeScript interfaces. Supported values are:
  • asInterfaces
  • asClasses
Default value is asInterfaces.
Value asClasses can only be used in implementation files (.ts). In this case it is also possible to generate constructors by setting generateConstructors parameter to true. It is also possible to generate mix of classes and interfaces by setting mapClasses parameter to asClasses value and specifying which classes should be mapped as classes using mapClassesAsClassesPatterns parameter.
<mapClassesAsClassesPatterns> List - Specifies which Java classes should be mapped as TypeScript classes. Classes which are matched by any of these patters are mapped as classes otherwise they are mapped as interfaces. This parameter can only be used when mapClasses parameter is set to asClasses value.
<mapDate> DateMapping - Specifies how Date will be mapped. Supported values are:
  • asDate - type Date
  • asNumber - type number
  • asString - type string
Default value is asDate.
<mapEnum> EnumMapping - Specifies how enums will be mapped. Supported values are:
  • asUnion - creates type alias to union of string enum values
  • asInlineUnion - creates union of enum values on places where the enum is used
  • asEnum - creates string enum. Requires TypeScript 2.4
  • asNumberBasedEnum - creates enum of named number values
Default value is asUnion.
See also nonConstEnums parameter.
<mapPackagesToNamespaces> boolean - Generates TypeScript namespaces from Java packages. Default is false.
<module> String - Name of generated ambient module.
Used when outputKind is set to ambientModule.
<moduleDependencies> List - List of modules (generated by typescript-generator!) on which currently generated module depends on. Each item of this list has
  • importFrom - (required) module name in generated import statement, can be relative path
  • importAs - (required) name that will be used when referring to the imports
  • infoJson - (required) file path to the module info JSON generated by preceding typescript-generator run, see generateInfoJson parameter
  • npmPackageName - (required when generating package.json) NPM dependency package name
  • npmVersionRange - (required when generating package.json) NPM dependency version (or other identification)
Only applicable when outputKind is set to module.
<namespace> String - Generates specified namespace.
Not recommended to combine with modules.
Default is no namespace.
<noEslintDisable> boolean - If true generated file will not be prevented from linting by ESLint. By default there is a eslint-disable comment that will force ESLint to ignore the generated file. This can be enabled to suppress this comment so that the file can be linted by ESLint.
<noFileComment> boolean - If true generated file will not contain comment at the top. By default there is a comment with timestamp and typescript-generator version. So it might be useful to suppress this comment if the file is in source control and is regenerated in build.
<noTslintDisable> boolean - If true generated file will not be prevented from linting by TSLint. By default there is a tslint:disable comment that will force TSLint to ignore the generated file. This can be enabled to suppress this comment so that the file can be linted by TSLint.
<nonConstEnumAnnotations> List - If this list is not empty, then generated enums will not have const keyword, if the enum contains one of the annotations defined in this list. See nonConstEnums
<nonConstEnums> boolean - If true generated enums will not have const keyword.
This can be used only in implementation files.
<npmBuildScript> String - Specifies NPM "build" script.
Only applicable when generateNpmPackageJson parameter is true and generating implementation file (.ts).
Default value is tsc --module umd --moduleResolution node --typeRoots --target es5 --lib es6 --declaration --sourceMap $outputFile.
<npmDependencies> List - List of additional NPM dependencies.
Only applicable when generateNpmPackageJson parameter is true and generating implementation file (.ts).
Each item it this list specifies dependency with its version.
Item format is: name:version.
<npmDevDependencies> List - List of additional NPM devDependencies.
Only applicable when generateNpmPackageJson parameter is true and generating implementation file (.ts).
Each item it this list specifies dependency with its version.
Item format is: name:version.
<npmName> String - Specifies NPM package name.
Only applicable when generateNpmPackageJson parameter is true.
Default value is ${project.artifactId}.
<npmPeerDependencies> List - List of additional NPM peerDependencies.
Only applicable when generateNpmPackageJson parameter is true and generating implementation file (.ts).
Each item it this list specifies dependency with its version.
Item format is: name:version.
<npmTypescriptVersion> String - Specifies TypeScript version declared in NPM package.json.
Default value is ^2.4.
<npmVersion> String - Specifies NPM package version.
Only applicable when generateNpmPackageJson parameter is true.
Default value is 1.0.0.
<nullabilityDefinition> NullabilityDefinition - Specifies how nullable types will be created in generated file. Nullable types are marked in Java by annotations specified using nullableAnnotations parameter like List<@Nullable String>. In Kotlin nullable types are marked using ? character like List<String?>. Value of this parameter specifies how nullable type is created from regular type T:
  • nullAndUndefinedUnion - type alias Nullable<T> which is defined as union of T | null | undefined
  • nullUnion - type alias Nullable<T> which is defined as union of T | null
  • undefinedUnion - type alias Nullable<T> which is defined as union of T | undefined
  • nullAndUndefinedInlineUnion - union of T | null | undefined without type alias
  • nullInlineUnion - union of T | null without type alias
  • undefinedInlineUnion - union of T | undefined without type alias
Default value is nullInlineUnion.
<nullableAnnotations> List - When any of specified annotations is used on a Java type typescript-generator treats this type as nullable. For example Java type List<@Nullable String> can be transformed to TypeScript as (string | null)[] (instead of just string[]). Exact nullability form depends on nullabilityDefinition parameter. Unlike optional properties nullable types can also be used "inside" other types like in previous example. Specified annotations must have target set to TYPE_PARAMETER or TYPE_USE. Example optional annotation: org.checkerframework.checker.nullness.qual.Nullable
<optionalAnnotations> List - The presence of any annotation in this list on a JSON property will cause the typescript-generator to treat that property as optional when generating the corresponding TypeScript interface. Example optional annotation: javax.annotation.Nullable. This parameter is "opposite" of requiredAnnotations, only one of them could be used.
<optionalProperties> OptionalProperties - Specifies how properties are defined to be optional. Supported values are:
  • useSpecifiedAnnotations - annotations specified using optionalAnnotations or requiredAnnotations parameter
  • useLibraryDefinition - examples: @JsonProperty(required = false) when using jackson2 library or @XmlElement(required = false) when using jaxb library
  • all - all properties are optional
Default value is useSpecifiedAnnotations.
<optionalPropertiesDeclaration> OptionalPropertiesDeclaration - Specifies how optional properties will be declared in generated file. This parameter applies to properties detected as optional. The detection can be specified using optionalProperties parameter. Supported values are:
  • questionMark - property will be marked using ? character as optional
  • questionMarkAndNullableType - property will be optional and it will also have union with null value
  • nullableType - property will not be optional but its type will be union with null value
  • nullableAndUndefinableType - property will not be optional but its type will be union with null and undefined values
  • undefinableType - property will not be optional but its type will be union with undefined value
Default value is questionMark.
<outputFile> File - Path and name of generated TypeScript file.
<outputFileType> TypeScriptFileType - Output file format, can be:
  • declarationFile (.d.ts)
  • implementationFile (.ts)
Setting this parameter to implementationFile allows to generate runnable TypeScript code.
Default value is declarationFile.
<primitivePropertiesRequired> boolean - When using requiredAnnotations to mark properties as not optional then setting this parameter to true marks also all properties of primitive type without explicit annotation.
<referencedFiles> List - List of files which will be referenced using triple-slash directive: /// <reference path="file" />. This can be used with customTypeMappings to provide needed TypeScript types.
<removeTypeNamePrefix> String - Prefix which will be removed from names of classes, interfaces, enums. For example if set to Json then mapping for JsonData will be Data.
<removeTypeNameSuffix> String - Suffix which will be removed from names of classes, interfaces, enums. For example if set to JSON then mapping for DataJSON will be Data.
<requiredAnnotations> List - Properties will be treated as optional except those annotated with any of specified annotations. This parameter is "opposite" of optionalAnnotations, only one of them could be used.
<restNamespacing> RestNamespacing - Specifies how JAX-RS REST operations will be grouped into objects. Supported values are:
  • singleObject - means that one object with all operations will be generated
  • perResource - means that for each root resource one object will be generated
  • byAnnotation - means that operations will be grouped by annotation specified using jaxrsNamespacingAnnotation
Default value is singleObject.
<restNamespacingAnnotation> String - Specifies annotation used for grouping JAX-RS REST operations. Format is annotationClass#annotationElement where annotationClass is fully-qualified class name and annotationElement is element name and defaults to value. Examples:
  • io.swagger.annotations.Api
  • io.swagger.annotations.Api#value

<restOptionsType> String - Specifies HTTP request options type in REST application. By default no options parameter is generated. Useful when passing additional parameters to underlying HTTP request method (like jQuery ajax settings or AxiosRequestConfig). Can be specific (for example AxiosRequestConfig) or generic (for example <O>).
<restResponseType> String - Specifies HTTP response type in REST application. Default value is Promise<R> which means data object returned asynchronously. This parameter is useful for example when underlying HTTP response object (like XMLHttpRequest or AxiosPromise) is returned instead of actual response data.
<scanSpringApplication> boolean - If true Spring REST application will be loaded and scanned for classes to process. It is needed to specify application class using another parameter (for example classes).
<scanningAcceptedPackages> List - Allows to speed up classpath scanning by limiting scanning to specified packages. This optimization applies to following parameters:
  • classPatterns
  • classesImplementingInterfaces
  • classesExtendingClasses
  • classesWithAnnotations
  • classesFromAutomaticJaxrsApplication
This parameter is passed directly to underlying classpath scanning library (ClassGraph) without any validation or interpretation.
<skip> boolean - (no description)
User property is: typescript.generator.skip.
<sortDeclarations> boolean - If true TypeScript declarations (interfaces, properties) will be sorted alphabetically.
<sortTypeDeclarations> boolean - If true TypeScript type declarations (interfaces) will be sorted alphabetically.
<stringQuotes> StringQuotes - Specifies how strings will be quoted. Supported values are:
  • doubleQuotes
  • singleQuotes
Default value is doubleQuotes.
<tsNoCheck> boolean - If true generated file will have disabled TypeScript semantic checks using @ts-nocheck comment.
<umdNamespace> String - Turns proper module into UMD (Universal Module Definition) with specified namespace. Only applicable to declaration files.

Parameter Details

<addTypeNamePrefix>

Prefix which will be added to names of classes, interfaces, enums. For example if set to I then mapping for Data will be IData.
  • Type: java.lang.String
  • Required: No

<addTypeNameSuffix>

Suffix which will be added to names of classes, interfaces, enums. For example if set to Data then mapping for Person will be PersonData.
  • Type: java.lang.String
  • Required: No

<additionalDataLibraries>

Allows to add support for specified libraries. Some libraries have special Jackson serializers and deserializers for their data types so this parameter allows to reflect actual JSON format of those data types. Note: specified library must be present in project dependencies (typescript-generator itself doesn't depend on those libraries). Supported libraries are:
  • Type: java.util.List
  • Required: No

<classPatterns>

Classes to process specified using glob patterns so it is possible to specify package or class name suffix. Glob patterns support two wildcards:
  • Single * wildcard matches any character except for . and $.
  • Double ** wildcard matches any character.
For more information and examples see Class Names Glob Patterns Wiki page.
  • Type: java.util.List
  • Required: No

<classes>

Classes to process.
  • Type: java.util.List
  • Required: No

<classesExtendingClasses>

Classes to process specified by extended superclasses.
  • Type: java.util.List
  • Required: No

<classesFromAutomaticJaxrsApplication>

Scans JAX-RS resources for JSON classes to process. It is possible to exclude particular REST resource classes using excludeClasses parameter.
  • Type: boolean
  • Required: No

<classesFromJaxrsApplication>

Scans specified JAX-RS Application for classes to process. Parameter contains fully-qualified class name. It is possible to exclude particular REST resource classes using excludeClasses parameter.
  • Type: java.lang.String
  • Required: No

<classesImplementingInterfaces>

Classes to process specified by implemented interface.
  • Type: java.util.List
  • Required: No

<classesWithAnnotations>

Classes to process specified by annotations.
  • Type: java.util.List
  • Required: No

<customTypeAliases>

List of custom type aliases. Each item it this list specifies type alias name (possibly with generic parameters) and its definition. Item format is: name:definition. For example for Unwrap<T>:T following type alias will be generated type Unwrap<T> = T. Other examples: SimpleName:VeryLongGeneratedName, StringID<T>:string.
  • Type: java.util.List
  • Required: No

<customTypeMappings>

List of custom mappings. Each item specifies TypeScript type which will be used for particular Java class. Item format is: javaClassName:typescriptType. For example mapping Joda-Time LocalDateTime to string would be added as org.joda.time.LocalDateTime:string. Mappings of generic classes must use syntax com.package.MyGenericClass<T1,T2>:TsGenericType2<T1,T2>. Instead of <T1,T2> it is also possible to use [T1,T2].
  • Type: java.util.List
  • Required: No

<customTypeNaming>

Specifies custom TypeScript names for Java classes. Multiple mappings can be specified, each using this format: javaClassName:typescriptName. This takes precedence over other naming settings. For more information and example see Type Mapping Wiki page.
  • Type: java.util.List
  • Required: No

<customTypeNamingFunction>

Specifies JavaScript function for getting custom TypeScript names for Java classes. Function can return undefined if default name should be used.
Function signature: function getName(className: string, classSimpleName: string): string | null | undefined;
Example function: function(name, simpleName) { if (name.startsWith('cz.')) return 'Test' + simpleName; }
  • Type: java.lang.String
  • Required: No

<customTypeProcessor>

Specifies custom class implementing TypeProcessor. This allows to customize how Java types are mapped to TypeScript. For example it is possible to implement TypeProcessor for Optional from guava.
  • Type: java.lang.String
  • Required: No

<debug>

Deprecated, use loggingLevel parameter.
  • Type: boolean
  • Required: No

<declarePropertiesAsOptional>

Deprecated, use optionalProperties parameter.
  • Type: boolean
  • Required: No

<declarePropertiesAsReadOnly>

If true declared properties will be readonly.
  • Type: boolean
  • Required: No

<disableJackson2ModuleDiscovery>

Deprecated, see jackson2ModuleDiscovery and jackson2Modules parameters.
  • Type: boolean
  • Required: No

<disableTaggedUnionAnnotations>

Specifies annotations used for disabling tagged union created from classes. In case of Jackson2 library this means class hierarchy formed using @JsonTypeInfo and @JsonSubTypes annotations. While disableTaggedUnions parameter only disables creation of TypeScript discriminated union types this parameter allows to disable also processing of discriminant property.
  • Type: java.util.List
  • Required: No

<disableTaggedUnions>

If true tagged unions will not be generated for Jackson 2 polymorphic types. This parameter does not disable processing of discriminant property. See also disableTaggedUnionAnnotations parameter.
  • Type: boolean
  • Required: No

<displaySerializerWarning>

Deprecated.
  • Type: boolean
  • Required: No

<enumMemberCasing>

Specifies how enum members will be named. Supported values are:
  • keepOriginal - keeps member name as is
  • PascalCase - converts name to Pascal case (upper camel case) convention
  • camelCase - converts name to lower camel case convention
Default value is keepOriginal.
  • Type: cz.habarta.typescript.generator.IdentifierCasing
  • Required: No

<excludeClassPatterns>

Excluded classes specified using glob patterns. For more information and examples see Class Names Glob Patterns Wiki page.
  • Type: java.util.List
  • Required: No

<excludeClasses>

List of classes excluded from processing.
  • Type: java.util.List
  • Required: No

<excludePropertyAnnotations>

Properties with any of these annotations will be excluded.
  • Type: java.util.List
  • Required: No

<extensions>

List of extensions specified as fully qualified class name. Known extensions:
  • cz.habarta.typescript.generator.ext.AxiosClientExtension} - generates client for JAX-RS service using Axios library, see JAX RS ApplicationWiki page
  • cz.habarta.typescript.generator.ext.BeanPropertyPathExtension} - generates type-safe property path getters
  • cz.habarta.typescript.generator.ext.TypeGuardsForJackson2PolymorphismExtension}
Parameter extensionsWithConfiguration can be used in case extension needs some configuration.
  • Type: java.util.List
  • Required: No

<extensionsWithConfiguration>

List of extensions with their configurations. This parameter has the same purpose as extensions parameter. Each item of this list has
  • className - required fully-qualified class name of the extension
  • configuration - optional Map with String keys and String values
  • Type: java.util.List
  • Required: No

<generateConstructors>

If true generated classes will also have constructors. Generated constructors use "named parameters" pattern so when calling such constructor parameters need to be wrapped in "options" object. This parameter can only be used when mapClasses parameter is set to asClasses value.
  • Type: boolean
  • Required: No

<generateInfoJson>

If true JSON file describing generated module will be generated. In following typescript-generator run this allows to generate another module which could depend on currently generated module. Generated JSON file contains mapping from Java classes to TypeScript types which typescript-generator needs when the module is referenced from another module using moduleDependencies parameter. Only applicable when outputKind is set to module.
  • Type: boolean
  • Required: No

<generateJaxrsApplicationClient>

If true client for JAX-RS REST application will be generated.
  • Type: boolean
  • Required: No

<generateJaxrsApplicationInterface>

If true interface for JAX-RS REST application will be generated.
  • Type: boolean
  • Required: No

<generateNpmPackageJson>

If true NPM package.json will be generated. Only applicable when outputKind is set to module. NPM package name and version can be specified using npmName and npmVersion parameters.
  • Type: boolean
  • Required: No

<generateReadonlyAndWriteonlyJSDocTags>

If true JSDoc tags @readonly and @writeonly will be generated on properties with read-only or write-only access.
  • Type: boolean
  • Required: No

<generateSpringApplicationClient>

If true client for Spring REST application will be generated.
  • Type: boolean
  • Required: No

<generateSpringApplicationInterface>

If true interface for Spring REST application will be generated.
  • Type: boolean
  • Required: No

<gsonConfiguration>

Specifies Gson global configuration. Description of individual parameters is in GsonConfiguration class on GitHub (latest version).
  • Type: cz.habarta.typescript.generator.GsonConfiguration
  • Required: No

<ignoreSwaggerAnnotations>

If true Swagger annotations will not be used.
  • Type: boolean
  • Required: No

<importDeclarations>

List of import declarations which will be added to generated output. This can be used with customTypeMappings to provide needed TypeScript types.
  • Type: java.util.List
  • Required: No

<includePropertyAnnotations>

If this list is not empty then only properties with any of these annotations will be included.
  • Type: java.util.List
  • Required: No

<indentString>

Specifies indentation string. In Maven pom.xml file it is needed to set xml:space attribute to preserve.
Example: <indentString xml:space="preserve"> </indentString>.
  • Type: java.lang.String
  • Required: No

<jackson2Configuration>

Specifies Jackson 2 global configuration. Description of individual parameters is in Jackson2Configuration class on GitHub (latest version).
  • Type: cz.habarta.typescript.generator.Jackson2Configuration
  • Required: No

<jackson2ModuleDiscovery>

Turns on Jackson2 automatic module discovery.
  • Type: boolean
  • Required: No

<jackson2Modules>

Specifies Jackson2 modules to use.
  • Type: java.util.List
  • Required: No

<javadocXmlFiles>

List of Javadoc XML files to search for documentation comments. These files should be created using com.github.markusbernhardt.xmldoclet.XmlDoclet from com.github.markusbernhardt:xml-doclet artifact. Javadoc comments are added to output declarations as JSDoc comments. For more information see Javadoc Wiki page.
  • Type: java.util.List
  • Required: No

<jaxrsNamespacing>

Deprecated, use restNamespacing.
  • Type: cz.habarta.typescript.generator.RestNamespacing
  • Required: No

<jaxrsNamespacingAnnotation>

Deprecated, use restNamespacingAnnotation.
  • Type: java.lang.String
  • Required: No

<jsonLibrary>

Library used in JSON classes. Supported values are:
  • jackson1 - annotations from `org.codehaus.jackson.annotate` package
  • jackson2 - annotations from `com.fasterxml.jackson.annotation` package
  • jaxb - annotations from `javax.xml.bind.annotation` package
  • gson - annotations from `com.google.gson.annotations` package
  • jsonb - annotations from `javax.json.bind.annotation` package
Required parameter, recommended value is jackson2.
  • Type: cz.habarta.typescript.generator.JsonLibrary
  • Required: Yes

<jsonbConfiguration>

Specifies JSON-B global configuration. Description of individual parameters is in Jackson2Configuration class on GitHub (latest version).
  • Type: cz.habarta.typescript.generator.JsonbConfiguration
  • Required: No

<loggingLevel>

Specifies level of logging output. Supported values are:
  • Debug
  • Verbose
  • Info
  • Warning
  • Error
Default value is Verbose.
  • Type: cz.habarta.typescript.generator.Logger$Level
  • Required: No

<mapClasses>

Specifies whether Java classes will be mapped to TypeScript classes or interfaces. Java interfaces are always mapped as TypeScript interfaces. Supported values are:
  • asInterfaces
  • asClasses
Default value is asInterfaces.
Value asClasses can only be used in implementation files (.ts). In this case it is also possible to generate constructors by setting generateConstructors parameter to true. It is also possible to generate mix of classes and interfaces by setting mapClasses parameter to asClasses value and specifying which classes should be mapped as classes using mapClassesAsClassesPatterns parameter.
  • Type: cz.habarta.typescript.generator.ClassMapping
  • Required: No

<mapClassesAsClassesPatterns>

Specifies which Java classes should be mapped as TypeScript classes. Classes which are matched by any of these patters are mapped as classes otherwise they are mapped as interfaces. This parameter can only be used when mapClasses parameter is set to asClasses value.
  • Type: java.util.List
  • Required: No

<mapDate>

Specifies how Date will be mapped. Supported values are:
  • asDate - type Date
  • asNumber - type number
  • asString - type string
Default value is asDate.
  • Type: cz.habarta.typescript.generator.DateMapping
  • Required: No

<mapEnum>

Specifies how enums will be mapped. Supported values are:
  • asUnion - creates type alias to union of string enum values
  • asInlineUnion - creates union of enum values on places where the enum is used
  • asEnum - creates string enum. Requires TypeScript 2.4
  • asNumberBasedEnum - creates enum of named number values
Default value is asUnion.
See also nonConstEnums parameter.
  • Type: cz.habarta.typescript.generator.EnumMapping
  • Required: No

<mapPackagesToNamespaces>

Generates TypeScript namespaces from Java packages. Default is false.
  • Type: boolean
  • Required: No

<module>

Name of generated ambient module.
Used when outputKind is set to ambientModule.
  • Type: java.lang.String
  • Required: No

<moduleDependencies>

List of modules (generated by typescript-generator!) on which currently generated module depends on. Each item of this list has
  • importFrom - (required) module name in generated import statement, can be relative path
  • importAs - (required) name that will be used when referring to the imports
  • infoJson - (required) file path to the module info JSON generated by preceding typescript-generator run, see generateInfoJson parameter
  • npmPackageName - (required when generating package.json) NPM dependency package name
  • npmVersionRange - (required when generating package.json) NPM dependency version (or other identification)
Only applicable when outputKind is set to module.
  • Type: java.util.List
  • Required: No

<namespace>

Generates specified namespace.
Not recommended to combine with modules.
Default is no namespace.
  • Type: java.lang.String
  • Required: No

<noEslintDisable>

If true generated file will not be prevented from linting by ESLint. By default there is a eslint-disable comment that will force ESLint to ignore the generated file. This can be enabled to suppress this comment so that the file can be linted by ESLint.
  • Type: boolean
  • Required: No

<noFileComment>

If true generated file will not contain comment at the top. By default there is a comment with timestamp and typescript-generator version. So it might be useful to suppress this comment if the file is in source control and is regenerated in build.
  • Type: boolean
  • Required: No

<noTslintDisable>

If true generated file will not be prevented from linting by TSLint. By default there is a tslint:disable comment that will force TSLint to ignore the generated file. This can be enabled to suppress this comment so that the file can be linted by TSLint.
  • Type: boolean
  • Required: No

<nonConstEnumAnnotations>

If this list is not empty, then generated enums will not have const keyword, if the enum contains one of the annotations defined in this list. See nonConstEnums
  • Type: java.util.List
  • Required: No

<nonConstEnums>

If true generated enums will not have const keyword.
This can be used only in implementation files.
  • Type: boolean
  • Required: No

<npmBuildScript>

Specifies NPM "build" script.
Only applicable when generateNpmPackageJson parameter is true and generating implementation file (.ts).
Default value is tsc --module umd --moduleResolution node --typeRoots --target es5 --lib es6 --declaration --sourceMap $outputFile.
  • Type: java.lang.String
  • Required: No

<npmDependencies>

List of additional NPM dependencies.
Only applicable when generateNpmPackageJson parameter is true and generating implementation file (.ts).
Each item it this list specifies dependency with its version.
Item format is: name:version.
  • Type: java.util.List
  • Required: No

<npmDevDependencies>

List of additional NPM devDependencies.
Only applicable when generateNpmPackageJson parameter is true and generating implementation file (.ts).
Each item it this list specifies dependency with its version.
Item format is: name:version.
  • Type: java.util.List
  • Required: No

<npmName>

Specifies NPM package name.
Only applicable when generateNpmPackageJson parameter is true.
Default value is ${project.artifactId}.
  • Type: java.lang.String
  • Required: No

<npmPeerDependencies>

List of additional NPM peerDependencies.
Only applicable when generateNpmPackageJson parameter is true and generating implementation file (.ts).
Each item it this list specifies dependency with its version.
Item format is: name:version.
  • Type: java.util.List
  • Required: No

<npmTypescriptVersion>

Specifies TypeScript version declared in NPM package.json.
Default value is ^2.4.
  • Type: java.lang.String
  • Required: No

<npmVersion>

Specifies NPM package version.
Only applicable when generateNpmPackageJson parameter is true.
Default value is 1.0.0.
  • Type: java.lang.String
  • Required: No

<nullabilityDefinition>

Specifies how nullable types will be created in generated file. Nullable types are marked in Java by annotations specified using nullableAnnotations parameter like List<@Nullable String>. In Kotlin nullable types are marked using ? character like List<String?>. Value of this parameter specifies how nullable type is created from regular type T:
  • nullAndUndefinedUnion - type alias Nullable<T> which is defined as union of T | null | undefined
  • nullUnion - type alias Nullable<T> which is defined as union of T | null
  • undefinedUnion - type alias Nullable<T> which is defined as union of T | undefined
  • nullAndUndefinedInlineUnion - union of T | null | undefined without type alias
  • nullInlineUnion - union of T | null without type alias
  • undefinedInlineUnion - union of T | undefined without type alias
Default value is nullInlineUnion.
  • Type: cz.habarta.typescript.generator.NullabilityDefinition
  • Required: No

<nullableAnnotations>

When any of specified annotations is used on a Java type typescript-generator treats this type as nullable. For example Java type List<@Nullable String> can be transformed to TypeScript as (string | null)[] (instead of just string[]). Exact nullability form depends on nullabilityDefinition parameter. Unlike optional properties nullable types can also be used "inside" other types like in previous example. Specified annotations must have target set to TYPE_PARAMETER or TYPE_USE. Example optional annotation: org.checkerframework.checker.nullness.qual.Nullable
  • Type: java.util.List
  • Required: No

<optionalAnnotations>

The presence of any annotation in this list on a JSON property will cause the typescript-generator to treat that property as optional when generating the corresponding TypeScript interface. Example optional annotation: javax.annotation.Nullable. This parameter is "opposite" of requiredAnnotations, only one of them could be used.
  • Type: java.util.List
  • Required: No

<optionalProperties>

Specifies how properties are defined to be optional. Supported values are:
  • useSpecifiedAnnotations - annotations specified using optionalAnnotations or requiredAnnotations parameter
  • useLibraryDefinition - examples: @JsonProperty(required = false) when using jackson2 library or @XmlElement(required = false) when using jaxb library
  • all - all properties are optional
Default value is useSpecifiedAnnotations.
  • Type: cz.habarta.typescript.generator.OptionalProperties
  • Required: No

<optionalPropertiesDeclaration>

Specifies how optional properties will be declared in generated file. This parameter applies to properties detected as optional. The detection can be specified using optionalProperties parameter. Supported values are:
  • questionMark - property will be marked using ? character as optional
  • questionMarkAndNullableType - property will be optional and it will also have union with null value
  • nullableType - property will not be optional but its type will be union with null value
  • nullableAndUndefinableType - property will not be optional but its type will be union with null and undefined values
  • undefinableType - property will not be optional but its type will be union with undefined value
Default value is questionMark.
  • Type: cz.habarta.typescript.generator.OptionalPropertiesDeclaration
  • Required: No

<outputFile>

Path and name of generated TypeScript file.
  • Type: java.io.File
  • Required: No

<outputFileType>

Output file format, can be:
  • declarationFile (.d.ts)
  • implementationFile (.ts)
Setting this parameter to implementationFile allows to generate runnable TypeScript code.
Default value is declarationFile.
  • Type: cz.habarta.typescript.generator.TypeScriptFileType
  • Required: No

<outputKind>

Kind of generated TypeScript output. Allowed values are:
  • global - means that declarations will be in global scope or namespace (no module)
  • module - means that generated file will contain top-level export declarations
  • ambientModule - means that generated declarations will be wrapped in declare module "mod" { } declaration
Required parameter. For more information see Modules and Namespaces Wiki page.
  • Type: cz.habarta.typescript.generator.TypeScriptOutputKind
  • Required: Yes

<primitivePropertiesRequired>

When using requiredAnnotations to mark properties as not optional then setting this parameter to true marks also all properties of primitive type without explicit annotation.
  • Type: boolean
  • Required: No

<referencedFiles>

List of files which will be referenced using triple-slash directive: /// <reference path="file" />. This can be used with customTypeMappings to provide needed TypeScript types.
  • Type: java.util.List
  • Required: No

<removeTypeNamePrefix>

Prefix which will be removed from names of classes, interfaces, enums. For example if set to Json then mapping for JsonData will be Data.
  • Type: java.lang.String
  • Required: No

<removeTypeNameSuffix>

Suffix which will be removed from names of classes, interfaces, enums. For example if set to JSON then mapping for DataJSON will be Data.
  • Type: java.lang.String
  • Required: No

<requiredAnnotations>

Properties will be treated as optional except those annotated with any of specified annotations. This parameter is "opposite" of optionalAnnotations, only one of them could be used.
  • Type: java.util.List
  • Required: No

<restNamespacing>

Specifies how JAX-RS REST operations will be grouped into objects. Supported values are:
  • singleObject - means that one object with all operations will be generated
  • perResource - means that for each root resource one object will be generated
  • byAnnotation - means that operations will be grouped by annotation specified using jaxrsNamespacingAnnotation
Default value is singleObject.
  • Type: cz.habarta.typescript.generator.RestNamespacing
  • Required: No

<restNamespacingAnnotation>

Specifies annotation used for grouping JAX-RS REST operations. Format is annotationClass#annotationElement where annotationClass is fully-qualified class name and annotationElement is element name and defaults to value. Examples:
  • io.swagger.annotations.Api
  • io.swagger.annotations.Api#value
  • Type: java.lang.String
  • Required: No

<restOptionsType>

Specifies HTTP request options type in REST application. By default no options parameter is generated. Useful when passing additional parameters to underlying HTTP request method (like jQuery ajax settings or AxiosRequestConfig). Can be specific (for example AxiosRequestConfig) or generic (for example <O>).
  • Type: java.lang.String
  • Required: No

<restResponseType>

Specifies HTTP response type in REST application. Default value is Promise<R> which means data object returned asynchronously. This parameter is useful for example when underlying HTTP response object (like XMLHttpRequest or AxiosPromise) is returned instead of actual response data.
  • Type: java.lang.String
  • Required: No

<scanSpringApplication>

If true Spring REST application will be loaded and scanned for classes to process. It is needed to specify application class using another parameter (for example classes).
  • Type: boolean
  • Required: No

<scanningAcceptedPackages>

Allows to speed up classpath scanning by limiting scanning to specified packages. This optimization applies to following parameters:
  • classPatterns
  • classesImplementingInterfaces
  • classesExtendingClasses
  • classesWithAnnotations
  • classesFromAutomaticJaxrsApplication
This parameter is passed directly to underlying classpath scanning library (ClassGraph) without any validation or interpretation.
  • Type: java.util.List
  • Required: No

<skip>

(no description)
  • Type: boolean
  • Required: No
  • User Property: typescript.generator.skip

<sortDeclarations>

If true TypeScript declarations (interfaces, properties) will be sorted alphabetically.
  • Type: boolean
  • Required: No

<sortTypeDeclarations>

If true TypeScript type declarations (interfaces) will be sorted alphabetically.
  • Type: boolean
  • Required: No

<stringQuotes>

Specifies how strings will be quoted. Supported values are:
  • doubleQuotes
  • singleQuotes
Default value is doubleQuotes.
  • Type: cz.habarta.typescript.generator.StringQuotes
  • Required: No

<tsNoCheck>

If true generated file will have disabled TypeScript semantic checks using @ts-nocheck comment.
  • Type: boolean
  • Required: No

<umdNamespace>

Turns proper module into UMD (Universal Module Definition) with specified namespace. Only applicable to declaration files.
  • Type: java.lang.String
  • Required: No