Skip to content

hntrl/sparktype

Repository files navigation

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.

Basic Usage

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):

{
  "$schema": "https://hntrl.github.io/sparktype/schema.json",
  "specs": {
    "api": { "path": "./openapi.yaml" }
  },
  "outputs": [
    { "path": "./types/api.ts", "format": "typescript", "contents": ["api:*"] }
  ]
}

2. Run the generator:

sparktype generate

3. 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";

Documentation

View the official sparktype documentation at hntrl.github.io/sparktype.

Contributing

We welcome contributions! Please see our CONTRIBUTING.md guide for more information on how to get involved.

License

Distributed under the MIT License. See the LICENSE for more information.

About

Generate static types from OpenAPI specifications

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published