Multiple Formats
Output schemas as TypeScript interfaces, Zod schemas, Python TypedDicts, or Go structs from a single source of truth.
Generate static type definitions from OpenAPI specifications for TypeScript, Python, and Go.
Install sparktype using your preferred package manager:
npm install -D sparktypepip install sparktypebrew install hntrl/tap/sparktypego install github.com/hntrl/sparktype/cmd/sparktype@latestCreate a typegen.jsonc configuration file:
{
"$schema": "https://hntrl.github.io/sparktype/schema.json",
"specs": {
"api": {
"path": "./openapi.yaml"
}
},
"outputs": [
{
"path": "./src/types/api.ts",
"format": "typescript",
"contents": ["api:*"]
}
]
}Generate your types:
sparktype generate{
"scripts": {
"types": "sparktype generate",
"types:check": "sparktype check"
}
}.PHONY: types
types:
sparktype generate
.PHONY: types-check
types-check:
sparktype check//go:generate sparktype generate
package mainThat's it! Your types are now generated and ready to use. See the Getting Started guide for a complete walkthrough.