OpenAPI 3.1 generation for hayate: routes from app.routes, schemas from your validators
Project description
hayate-openapi
OpenAPI 3.1 generation for hayate —
built from what your app already knows: routes from app.routes, request
schemas from your validators, response schemas from one decorator. No magic
inference, no schema-library lock-in.
Status: alpha (0.1.x). The emitted document passes the official
openapi-spec-validatorand feedsopenapi-typescriptfor end-to-end TypeScript types. The internal design memo (Japanese, per project convention) lives in DESIGN.md.
from hayate import Hayate
from hayate_openapi import OpenApi, describe, validated
import msgspec
class BookIn(msgspec.Struct):
title: str
app = Hayate()
@app.post("/books", validated("json", BookIn)) # validator + schema tag in one
@describe(status=201, summary="Create a book")
async def create(c):
book = c.req.valid("json") # BookIn instance — validation still runs
return c.json({"title": book.title}, status=201)
OpenApi(app, title="Bookstore", version="1.0.0").register(app)
# GET /openapi.json is live; or emit statically:
# python -m hayate_openapi main:app --title Bookstore --version 1.0.0
How it works
| Source | What it provides |
|---|---|
app.routes (hayate ≥ 0.8) |
every method + path, converted to OpenAPI templating (:id → {id}) |
validated(target, T) |
request body / query / form schemas — a tagging wrapper around the core validator, behavior-identical |
@describe(...) |
summary, tags, response schemas, operationId — all optional, all additive |
Schema conversion goes through a SchemaProvider protocol. msgspec and
pydantic are auto-detected (guarded imports); a plain dict is taken as
literal JSON Schema. The package itself depends only on hayate.
TypeScript types, the recommended recipe:
python -m hayate_openapi main:app --title API --version 1.0.0 -o openapi.json
npx openapi-typescript openapi.json -o src/api-types.ts
Docs UI: serve the JSON and point any renderer at it — e.g. one line of Scalar or Redoc HTML. Nothing is bundled.
What is documented (and what is not)
- Routes with real HTTP verbs; WebSocket routes and wildcard mounts
(
/api/auth/*) are skipped. - Responses you declare. Undeclared operations get a bare 200 — the generator never invents schemas.
- Operations with a validator automatically document the 400
application/problem+jsonfailure the framework actually returns.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hayate_openapi-0.1.0.tar.gz.
File metadata
- Download URL: hayate_openapi-0.1.0.tar.gz
- Upload date:
- Size: 7.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9661d1f73bb68afb5fc443d817979605de05d861f302ee92137b6b2a238f56ff
|
|
| MD5 |
205648d148fba0bbc2beb30662c4a7a2
|
|
| BLAKE2b-256 |
73e6a993851a66e6702a20aeb6922f057ee9339e60ffdb82a148e5af0195ce6d
|
Provenance
The following attestation bundles were made for hayate_openapi-0.1.0.tar.gz:
Publisher:
release.yml on hayatepy/hayate-openapi
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hayate_openapi-0.1.0.tar.gz -
Subject digest:
9661d1f73bb68afb5fc443d817979605de05d861f302ee92137b6b2a238f56ff - Sigstore transparency entry: 2219639794
- Sigstore integration time:
-
Permalink:
hayatepy/hayate-openapi@08a248ae39de5fe20671727e0f96586b21c10c7f -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/hayatepy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@08a248ae39de5fe20671727e0f96586b21c10c7f -
Trigger Event:
push
-
Statement type:
File details
Details for the file hayate_openapi-0.1.0-py3-none-any.whl.
File metadata
- Download URL: hayate_openapi-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d404d0d2a775f854ede5b0409b613d285ab58a753bb1b56df62a9ba955d421d
|
|
| MD5 |
a4dedb44d37657c22daf73d12ebf848b
|
|
| BLAKE2b-256 |
8a589a6c8c6c3309044967236bdb0c81c7ccdb6441c2f91792b91545612178f6
|
Provenance
The following attestation bundles were made for hayate_openapi-0.1.0-py3-none-any.whl:
Publisher:
release.yml on hayatepy/hayate-openapi
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hayate_openapi-0.1.0-py3-none-any.whl -
Subject digest:
4d404d0d2a775f854ede5b0409b613d285ab58a753bb1b56df62a9ba955d421d - Sigstore transparency entry: 2219639813
- Sigstore integration time:
-
Permalink:
hayatepy/hayate-openapi@08a248ae39de5fe20671727e0f96586b21c10c7f -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/hayatepy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@08a248ae39de5fe20671727e0f96586b21c10c7f -
Trigger Event:
push
-
Statement type: