sparktype is a cross-platform CLI tool that generates static type definitions from OpenAPI specifications.
- Multiple formats 📦: Output schemes in Python, TypeScript, and Go
- CI-Friendly 🔋: Detects drift between specs and generated types
- Filtering & Organizing 🔍: Include/exclude and organize schemas by glob patterns
- Cross-platform 🌐: Available via npm, pip, Homebrew, or direct download
You can learn more about the use cases and features of sparktype in the official documentation.
The best way to get started using sparktype is by checking out the getting started guide.
Here's a quick example of how to use sparktype to generate types from a basic OpenAPI specification:
1. Create a config file (typegen.jsonc):
2. Run the generator:
sparktype generate3. Get type-safe output:
// types/api.ts - Generated by sparktype
export interface User {
/** Unique identifier */
id: string;
email: string;
name?: string;
role: UserRole;
}
export type UserRole = "admin" | "user" | "guest";View the official sparktype documentation at hntrl.github.io/sparktype.
We welcome contributions! Please see our CONTRIBUTING.md guide for more information on how to get involved.
Distributed under the MIT License. See the LICENSE for more information.
{ "$schema": "https://hntrl.github.io/sparktype/schema.json", "specs": { "api": { "path": "./openapi.yaml" } }, "outputs": [ { "path": "./types/api.ts", "format": "typescript", "contents": ["api:*"] } ] }