06 · Reference

The complete spec, served locally.

View as Markdown

Every endpoint, every field, every schema is in the OpenAPI 3 document served at http://127.0.0.1:10108/openapi.json by your desktop install. Use it for codegen, client validation, or to point Swagger UI at.

Fetch the spec

curl -sS http://127.0.0.1:10108/openapi.json \
  -H "Authorization: Bearer $DONUT_API_KEY" > openapi.json
import { writeFile } from "node:fs/promises";

const response = await fetch("http://127.0.0.1:10108/openapi.json", {
  headers: { Authorization: `Bearer ${process.env.DONUT_API_KEY}` },
});

await writeFile("openapi.json", await response.text());
import os, json, requests

response = requests.get(
    "http://127.0.0.1:10108/openapi.json",
    headers={"Authorization": f"Bearer {os.environ['DONUT_API_KEY']}"},
    timeout=10,
)
with open("openapi.json", "w") as f:
    json.dump(response.json(), f, indent=2)
Invoke-RestMethod -Uri "http://127.0.0.1:10108/openapi.json" `
    -Headers @{ Authorization = "Bearer $env:DONUT_API_KEY" } |
  ConvertTo-Json -Depth 100 |
  Set-Content -Path "openapi.json"

Codegen

Generate strongly typed clients in your language of choice:

# TypeScript — generate typed bindings from the live spec
npx openapi-typescript http://127.0.0.1:10108/openapi.json \
  --output donut-api.d.ts \
  --header "Authorization: Bearer $DONUT_API_KEY"
# Python — openapi-generator generates a fully typed sync client
openapi-generator-cli generate \
  -i openapi.json \
  -g python \
  -o ./donut_client
# Go — oapi-codegen generates idiomatic Go bindings
go install github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@latest
oapi-codegen -package donut -o donut/client.go openapi.json
# Rust
openapi-generator-cli generate \
  -i openapi.json \
  -g rust \
  -o ./donut-client-rs

Interactive explorer

Point a Swagger UI at the spec for a clickable reference. Paste your bearer token into the Authorize dialog and you can hit your own running Donut Browser from the browser.

# Docker — open the spec in Swagger UI locally
docker run -p 8080:8080 \
  -e SWAGGER_JSON=/openapi.json \
  -v $(pwd)/openapi.json:/openapi.json \
  swaggerapi/swagger-ui
# VS Code — use the "OpenAPI (Swagger) Editor" extension; opens
# any openapi.json with a built-in clickable explorer.
code openapi.json