Skip to content

Emitter usage

  1. Via the command line
Terminal window
tsp compile . --emit=@azure-tools/typespec-java
  1. Via the config
emit:
- "@azure-tools/typespec-java"

The config can be extended with options as follows:

emit:
- "@azure-tools/typespec-java"
options:
"@azure-tools/typespec-java":
option: value

Type: absolutePath

Defines the emitter output directory. Defaults to {output-dir}/@azure-tools/typespec-java See Configuring output directory for more info

Type: string

Specifies the namespace you want to override for namespaces set in the spec. With this config, all namespace for the spec types will default to it.

Type: string

Specify the human readable name of the service. The name will be used for classes like <ServiceName>Manager or <ServiceName>ServiceVersion

Type: string

Specifies the directory for legacy JSON example files and disables unified YAML discovery. When unset, TCGC looks for examples.yaml or examples/*.yaml at the project root, falling back to legacy JSON files in examples when no unified files are present.

Type: boolean

Default: true

When set to true, the emitter will generate Java sample code. Default value is true.

Type: boolean

Default: true

When set to true, the emitter will generate Java test code (mock test for management-plane SDK, disabled live test for data-plane SDK). Default value is true.

Type: boolean

Default: true

When set to true, the generated SDK uses synchronous REST API invocation. Default value is true. This option is to be deprecated.

Type: boolean

Default: true

When set to true, the generated SDK uses stream style serialization. Default value is true. This option is to be deprecated.

Type: boolean

Default: false

When set to true, the emitter generates Java Object for TypeSpec unknown; otherwise, the emitter generates BinaryData. Default value is false. This option is for backward-compatibility.

Type: boolean

Default: false

When set to true, the model classes would be generated with a validate() API for validating required properties, during REST API invocation. Default value is false. This option is for backward-compatibility.

Type: boolean

Default: true

When set to true, the emitter generates Java double for TypeSpec float32; otherwise, the emitter generates float. Default value is true. This option is for backward-compatibility.

Type: boolean

Default: true

When set to true, the emitter generates Java String for TypeSpec Azure.Core.uuid; otherwise, the emitter generates UUID. Default value is true. This option is for backward-compatibility.

Type: boolean

When set to true, the emitter will generate low-level protocol methods for each service operation if @protocolAPI is not set for an operation. Default value is true.

Type: boolean

When set to true, the emitter will generate convenience methods for each service operation if @convenientAPI is not set for an operation. Default value is true.

Type: boolean

Default: false

When set to true, the emitter will merge the generated code with existing code on emitter-output-dir, during post-process. Default value is false.

Type: string

Specify the package name for model classes. Default value is models.

Type: string

Specify the Java class names for custom model classes.

Type: string

Specify the package name for custom model classes.

Type: string

Specify the Java class that to be executed by emitter for code customization, during post-process.

Type: string,object

Rename the model classes, in case they cannot be renamed via TCGC. E.g., anonymous models or templated models. Format should be in key-value form.

Type: string[]

Specify headers that emitter will ignore.

Type: boolean

Default: false

When set to true, the generated SDK uses getter method to access child clients. Default value is false.

Type: "model"

When set to model, generate the maximum set of model-based convenience method overloads for Azure clients.

Type: string | object

Use this flag if you would like to generate the sdk only for a specific version. Default value is the latest version. Also accepts values latest and all. For multi-service packages, provide a map from each service namespace to its desired version. Nested namespaces must be represented as nested objects in tspconfig.yaml; services not listed default to their latest version.

Options:

  • string
  • object

Type: boolean

Default: false

When set to true, the emitter will take the history of api-versions in TypeSpec, and try generate SDK without breaking changes compared to SDK generated from prior api-versions. Default value is false. This is an experimental feature.

Type: boolean

Default: false

When set to true, the emitter will not include ##-preview api-versions in ServiceVersion class, if the release targets a stable api-version. Default value is true. The option should be set to true, if the intended release is SDK of stable version.

Type: object { generate-code-model, debug, loglevel, java-temp-dir, profile }

Developer options for http-client-java emitter.

Properties:

NameTypeDefaultDescription
generate-code-modelbooleanGenerate intermittent ‘code-model.yaml’ file in output directory.
debugbooleanEnable Java remote debug on port 5005.
loglevel"off" | "debug" | "info" | "warn" | "error"Log level for Java logging. Default is ‘warn’.
java-temp-dirstringTemporary working directory for Java code generator.
profilebooleanEnable performance profiling.