Skip to content

sparktype ⚡Type-safe OpenAPI

Generate static type definitions from OpenAPI specifications for TypeScript, Python, and Go.

Quick Start

Install sparktype using your preferred package manager:

sh
npm install -D sparktype
sh
pip install sparktype
sh
brew install hntrl/tap/sparktype
sh
go install github.com/hntrl/sparktype/cmd/sparktype@latest

Create a typegen.jsonc configuration file:

jsonc
{
  "$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:

sh
sparktype generate
json
{
  "scripts": {
    "types": "sparktype generate",
    "types:check": "sparktype check"
  }
}
makefile
.PHONY: types
types:
	sparktype generate

.PHONY: types-check
types-check:
	sparktype check
go
//go:generate sparktype generate
package main

That's it! Your types are now generated and ready to use. See the Getting Started guide for a complete walkthrough.

Released under the MIT License.