Metadata-Version: 2.5
Name: action0-client-openapi
Version: 0.1.1
Summary: Generate fully typed action0-client API clients — operation classes and models — from an OpenAPI schema
Project-URL: Homepage, https://github.com/LaughInJar/action0-client-openapi
Project-URL: Documentation, https://laughinjar.github.io/action0-client-openapi/
Project-URL: Source, https://github.com/LaughInJar/action0-client-openapi
Project-URL: Issues, https://github.com/LaughInJar/action0-client-openapi/issues
Author: Simon Lachinger
License-Expression: MIT
License-File: LICENSE
Keywords: api,client,codegen,generator,http,openapi,swagger,typed
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Software Development :: Code Generators
Classifier: Topic :: Software Development :: Libraries
Classifier: Typing :: Typed
Requires-Python: >=3.11
Requires-Dist: action0-client>=0.1.0
Provides-Extra: yaml
Requires-Dist: pyyaml>=6.0; extra == 'yaml'
Description-Content-Type: text/markdown

# Action0-Client-OpenAPI

[![CI](https://github.com/LaughInJar/action0-client-openapi/actions/workflows/ci.yml/badge.svg)](https://github.com/LaughInJar/action0-client-openapi/actions/workflows/ci.yml)
[![PyPI](https://img.shields.io/pypi/v/action0-client-openapi)](https://pypi.org/project/action0-client-openapi/)

Generate fully typed
[action0-client](https://github.com/LaughInJar/action0-client) API
clients from an OpenAPI schema: one typed operation class per endpoint,
plus the model classes their results are parsed into. The generated code
is plain, readable `action0-client` code — it depends on
`action0-client` only, not on this package — so it runs synchronously,
on asyncio, on Twisted or on an execution model of your own, decided by
the backend you plug in.

```shell
uv add --dev action0-client-openapi     # or: pip install action0-client-openapi
action0-openapi petstore.json -o src/   # YAML schemas: install the "yaml" extra
```

```
src/petstore_client/__init__.py
src/petstore_client/client.py
src/petstore_client/models.py
src/petstore_client/operations.py
src/petstore_client/py.typed
```

Using the generated client — the backend decides the execution model,
and the static types follow it:

```python
from action0.client.backends.requests import RequestsBackend
from petstore_client import GetPet, PetstoreClient

client = PetstoreClient(RequestsBackend(), token="...")
pet = client.send(GetPet(pet_id=42))  # Pet

from action0.client.backends.httpx import AsyncHttpxBackend

client = PetstoreClient(AsyncHttpxBackend(), token="...")
pet = await client.send(GetPet(pet_id=42))  # Awaitable[Pet]
```

Generated code is meant to be checked in and reviewed like hand-written
code: it is readable, ruff-clean and fully typed — mypy strict, pyright
and ty pass on it. Models become plain dataclasses with generated
JSON converters, endpoints become `Operation` subclasses, security
schemes become client constructor credentials — with the schema's
`description`s carried along as docstrings and `#:` doc-comments. The [schema support
matrix](https://laughinjar.github.io/action0-client-openapi/usage/schema-support.html)
lists exactly which OpenAPI 3.0/3.1 constructs are covered — schemas
split over several files are bundled automatically, straight from a URL
too (referenced files download after a per-file confirmation, or with
`--download`) — and what is deliberately deferred (typed multipart
bodies, per-status response typing, ...).

Requires Python 3.11 or newer.

Full documentation including the API reference:
<https://laughinjar.github.io/action0-client-openapi/>

## Development

The project is managed with [uv](https://docs.astral.sh/uv/); `uv run`
syncs the environment automatically:

```shell
uv run pytest          # tests (incl. doctests in the sources)
uv run ruff check      # lint
uv run ruff format     # format
uv run mypy            # type-check (strict)
uv run pyright         # type-check
uv run ty check        # type-check
```

## AI disclosure

This library is developed with heavy use of AI coding tools: the code,
tests, and documentation are largely written by
[Claude Code](https://claude.com/claude-code), working from the author's
design brief and reviewed by the author. If that changes how much you want
to rely on this package, that's a fair call — read the source, it's small.

## License

MIT — see [LICENSE](LICENSE).
