Skip to content

Targets

Typra emits generated model surfaces, tests, metadata, and documentation from the same TypeSpec source.

TargetGenerated surface
TypeScriptModel classes, runtime helpers, JSON/YAML helpers, tests, protocol scaffold tests, and optional Zod validators.
PythonModel surfaces, loader/saver helpers, JSON/YAML helpers, import-pruned output, tests, and optional Pydantic v2 models.
CSharpC# model types, System.Text.Json helpers, tests, and protocol scaffolds.
GoStructs, load/save helpers, JSON/YAML helpers, scalar shorthand coercion, polymorphic dispatch, and generated tests.
JavaModels with load, save, fromJson, toJson, fromYaml, toYaml, scalar coercion, enum handling, polymorphic dispatch, tests, and optional Jackson interop.
Ruststructs with from_json/to_json, from_yaml/to_yaml, provider wire mapping, optional case-insensitive enum parsing, and optional explicit serde impls.
SwiftA SwiftPM package with TypraModel types, fromJSON/toJSON, fromYAML/toYAML, scalar coercion, polymorphic enums, provider wire mapping, optional explicit Codable, and XCTest tests.
TargetGenerated surface
MarkdownReference documentation output generated from the contract graph. Review copy before publishing product docs.
JSON ASTjson-ast/model.json, emitted for every generation for tooling, verification, and review.

Every target entry requires type. Most targets also use output-dir; tests are emitted only when test-dir is set.

emit-targets:
- type: TypeScript
output-dir: "generated/typescript"
test-dir: "generated/typescript/tests"
import-path: "../index"
- type: CSharp
output-dir: "generated/csharp"
test-dir: "generated/csharp/tests"
namespace: "Todo.Contracts"
- type: Java
output-dir: "generated/java"
test-dir: "generated/java/tests"
package-name: "todo.contracts"
JobTarget choice
Browser or Node consumersStart with TypeScript.
Service or data tooling in PythonAdd Python.
.NET product surfacesAdd CSharp and set namespace.
Go services or CLIsAdd Go and set package-name.
JVM consumersAdd Java and set package-name.
Rust consumersAdd Rust; choose enum-parsing deliberately.
Apple platforms or Swift servicesAdd Swift and set package-name.
Human-readable contract referenceAdd Markdown.
Tooling, review, or schema evolutionUse the always-emitted JSON AST.
TargetExample page
TypeScriptTypeScript target
PythonPython target
CSharpC# target
GoGo target
JavaJava target
RustRust target
SwiftSwift target
MarkdownMarkdown target

Target support is intentionally evidence-driven. The fixture suite validates generated compile/test surfaces, but runtime helper breadth differs by language.

TargetCaveat to check before adopting
TypeScript, Python, GoBest fit when JSON/YAML helper behavior and scalar shorthand loading matter.
CSharp, JavaConfirm package/namespace conventions before publishing generated output. Both include JSON and YAML helper surfaces.
RustChoose enum-parsing deliberately; default behavior is case-sensitive. Use native-serialization: "serde" when consumers need serde interop.
SwiftEmits a SwiftPM package with a Yams dependency for YAML; use native-serialization: "codable" when consumers need JSONEncoder/JSONDecoder interop. Requires a Swift toolchain to build and test.
MarkdownTreat as generated reference output, not a replacement for product narrative docs.
JSON ASTUse for tooling and review; do not treat it as a runtime API.

The Typra fixture slice validates TypeScript, Python, C#, Go, Java, Rust, Swift, Markdown, and JSON AST generation from synthetic TypeSpec shapes. Fixture validation also exercises generated metadata, verifier CLI output, consumer smoke wiring, native-interop variants (typescript-zod, python_pydantic, java-jackson, rust-serde, and swift-codable), and cross-language generated-code compile/test surfaces. For Go, that includes gofmt, go vet, go test, scalar coercion helper coverage, and executable conformance. Swift build and test run when a Swift toolchain is available, and are gated to a hard requirement with CI_SWIFT_REQUIRED=1.

The fixture source is the compact reference for supported shapes:

packages\typra-emitter\fixtures\tspconfig.yaml
packages\typra-emitter\fixtures\integration\main.tsp
packages\typra-emitter\fixtures\features\<feature>\main.tsp
packages\typra-emitter\fixtures\runtimes\<runtime>\<case>\main.tsp