Emitter usage
Emitter usage
Section titled “Emitter usage”- Via the command line
tsp compile . --emit=@azure-tools/typespec-java- 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: valueEmitter options
Section titled “Emitter options”emitter-output-dir
Section titled “emitter-output-dir”Type: absolutePath
Defines the emitter output directory. Defaults to {output-dir}/@azure-tools/typespec-java
See Configuring output directory for more info
namespace
Section titled “namespace”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.
service-name
Section titled “service-name”Type: string
Specify the human readable name of the service. The name will be used for classes like <ServiceName>Manager or <ServiceName>ServiceVersion
examples-dir
Section titled “examples-dir”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.
generate-samples
Section titled “generate-samples”Type: boolean
Default: true
When set to true, the emitter will generate Java sample code. Default value is true.
generate-tests
Section titled “generate-tests”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.
enable-sync-stack
Section titled “enable-sync-stack”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.
stream-style-serialization
Section titled “stream-style-serialization”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.
use-object-for-unknown
Section titled “use-object-for-unknown”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.
client-side-validations
Section titled “client-side-validations”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.
float32-as-double
Section titled “float32-as-double”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.
uuid-as-string
Section titled “uuid-as-string”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.
generate-protocol-methods
Section titled “generate-protocol-methods”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.
generate-convenience-methods
Section titled “generate-convenience-methods”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.
partial-update
Section titled “partial-update”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.
models-subpackage
Section titled “models-subpackage”Type: string
Specify the package name for model classes. Default value is models.
custom-types
Section titled “custom-types”Type: string
Specify the Java class names for custom model classes.
custom-types-subpackage
Section titled “custom-types-subpackage”Type: string
Specify the package name for custom model classes.
customization-class
Section titled “customization-class”Type: string
Specify the Java class that to be executed by emitter for code customization, during post-process.
rename-model
Section titled “rename-model”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.
skip-special-headers
Section titled “skip-special-headers”Type: string[]
Specify headers that emitter will ignore.
enable-subclient
Section titled “enable-subclient”Type: boolean
Default: false
When set to true, the generated SDK uses getter method to access child clients. Default value is false.
max-overload
Section titled “max-overload”Type: "model"
When set to model, generate the maximum set of model-based convenience method overloads for Azure clients.
api-version
Section titled “api-version”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:
stringobject
advanced-versioning
Section titled “advanced-versioning”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.
service-version-exclude-preview
Section titled “service-version-exclude-preview”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.
dev-options
Section titled “dev-options”Type: object { generate-code-model, debug, loglevel, java-temp-dir, profile }
Developer options for http-client-java emitter.
Properties:
| Name | Type | Default | Description |
|---|---|---|---|
generate-code-model | boolean | Generate intermittent ‘code-model.yaml’ file in output directory. | |
debug | boolean | Enable Java remote debug on port 5005. | |
loglevel | "off" | "debug" | "info" | "warn" | "error" | Log level for Java logging. Default is ‘warn’. | |
java-temp-dir | string | Temporary working directory for Java code generator. | |
profile | boolean | Enable performance profiling. |