alt-stack-openapi-pydantic
Generate Python 3.11+ Pydantic 2 models, statically typed Request/Response route maps, and an asyncio HttpxApiClient from OpenAPI JSON. This is the Python counterpart of @alt-stack/zod-openapi; the generated client runs on alt-stack-http-client-httpx.
Install
python -m pip install alt-stack-openapi-pydantic
Consumers of a generated SDK install the runtime package instead:
python -m pip install alt-stack-http-client-httpx
Generate
alt-stack-openapi-pydantic ./openapi.json --output ./generated_types.py
input may be a local JSON path or HTTP(S) URL. Use --registry to execute custom type mappings and --include to insert imports/definitions into output.
from generated_types import User
user = User.model_validate({"id": "u_1", "name": "Ada"})
The CLI enables route generation and emits Request/Response dictionaries whose leaves are Pydantic model classes. The dictionaries carry generated TypedDict annotations, so type checkers resolve literal lookups to the exact model and reject unknown paths, methods, request parts, and status codes:
from generated_types import Request, Response
Request["/users"]["POST"]["body"] # type[CreateUserBody]
Response["/users/{id}"]["GET"]["200"] # type[User]
Response["/users/{id}"]["GET"]["999"] # static error: unknown status
Generated modules also include an asyncio HttpxApiClient with one typed method per route, built on alt_stack_http_client_httpx:
from alt_stack_http_client_httpx import ApiSuccess
from generated_types import GetUsersIdParams, HttpxApiClient, Request, Response
async with HttpxApiClient(
"https://api.example.com", request_map=Request, response_map=Response
) as client:
result = await client.get("/users/{id}", params=GetUsersIdParams(id="u_1"))
if isinstance(result, ApiSuccess):
result.body # User; unknown paths, missing params, and wrong models are static errors
Generated modules that use non-object intersections inline a small all_of validator, so they depend only on pydantic and alt-stack-http-client-httpx at runtime.
Development
uv run --project packages/python-pydantic-openapi --extra dev pytest packages/python-pydantic-openapi/tests
uv run --project packages/python-pydantic-openapi --extra dev ruff check packages/python-pydantic-openapi
uv run --project packages/python-pydantic-openapi --extra dev ty check packages/python-pydantic-openapi
Documentation
Metadata
Release files for alt-stack-openapi-pydantic 1.6.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| alt_stack_openapi_pydantic-1.6.3.tar.gz | 35.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| alt_stack_openapi_pydantic-1.6.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 62.6 kB
Release files / alt_stack_openapi_pydantic-1.6.3.tar.gz
| Download URL | alt_stack_openapi_pydantic-1.6.3.tar.gz |
|---|---|
| Size | 35.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3f90afdc5df4bea102fe061c835d2d5b360dcf61989decbd676159f0336377df
|
|
BLAKE2b-256 checksum How to use checksums |
856cc3ac7f4b90ad060d592403316b0796380705e0f9519c169b7ed44da2acc5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 11, 2026.
Transparency logRelease files / alt_stack_openapi_pydantic-1.6.3-py3-none-any.whl
| Download URL | alt_stack_openapi_pydantic-1.6.3-py3-none-any.whl |
|---|---|
| Size | 26.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d12fad3c207ed62bd20c65532207bd98e3f6bc5a62319067537743b193390a78
|
|
BLAKE2b-256 checksum How to use checksums |
9eea6e73a58b68c01b3d3d2d49d5faa5e687366a37b0468b30d3d3ba4fe98d7c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 11, 2026.
Transparency log