Generate static types from OpenAPI specifications
npm install sparktypeGenerate static types from OpenAPI specifications.
``bash`
npm install -g sparktypeor
npx sparktype generate
`bashGenerate types using typegen.jsonc in current directory
sparktype generate
Configuration
Create a
typegen.jsonc file:`jsonc
{
"specs": {
"api": {
"path": "./openapi.yaml"
}
},
"outputs": [
{
"path": "./src/types/api.ts",
"format": "typescript",
"spec": "api"
}
]
}
`Supported Output Formats
-
typescript - TypeScript interfaces
- zod - Zod schemas with inferred types
- python - Python TypedDict classes
- go` - Go structs with JSON tagsFor full documentation, visit: https://github.com/hntrl/sparktype