TypeSpec lets teams describe REST, OpenAPI, gRPC, JSON Schema, and Protobuf APIs in one place and emit specs, code, and docs.
Overview
TypeSpec is a language and toolchain for describing APIs and related data models as a single source of truth. It is designed to be extended with libraries and emitters so one definition can produce OpenAPI documents, JSON Schema, Protobuf, client code, server stubs, and documentation.
The syntax is inspired by TypeScript and stays minimal while supporting REST patterns through HTTP libraries, validation through linters, and packaging of reusable API patterns. Microsoft built the core project with community contributions, and emitters control how output is shaped for each ecosystem.
Day-to-day use involves writing `.tsp` files, installing packages such as HTTP, REST, and OpenAPI emitters, and running the compiler to emit artifacts into an output folder. A VS Code extension is available from the marketplace or via command-line installation for editor integration.
TypeSpec emphasizes guardrails for API designers, including linter rules for anti-patterns and shared pattern libraries so teams align on conventions before code is generated.
Key features
- Multi-protocol API definitions
- OpenAPI 3 emission
- JSON Schema 2020-12 emission
- Protobuf generation
- Reusable pattern libraries
- Linter framework for APIs
- VS Code extension
- Emitter plugin architecture
Use cases
- Generating OpenAPI from one TypeSpec model
- Standardizing REST services across teams
- Producing JSON Schema for validation pipelines
- Emitting Protobuf for gRPC services
- Sharing API design libraries internally