You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
book = client.get("/books/{book_id}")(params={"book_id": 1})
76
69
```
77
70
71
+
See [Custom transport](#custom-transport) on how to build a custom transport.
78
72
79
-
## Extensibility
80
-
81
-
`GeneratorExtensions` exposes two safe hooks:
82
-
83
-
-`normalize_hooks`: transform the normalized model before rendering.
84
-
-`render_context_hooks`: transform rendered file content map before writing.
85
-
86
-
## Transport Decoupling
73
+
## Protocols
87
74
88
75
Generated clients expose a transport protocol. You can plug in your own transport while keeping route-level typing guarantees.
89
76
90
-
Use `--protocol-only` to generate clients that require a supplied transport and do not emit the built-in `httpx` transport classes. By default, generated clients include `DefaultTransport` and `DefaultAsyncTransport`, which require the `httpx` extra when instantiated.
91
-
92
-
Protocol typing can be relaxed independently with `--no-routes`, `--no-requests`, and `--no-responses`. Those flags replace the corresponding route literals, request payload types, or response types with broad catch-all types.
93
-
94
-
### Built-in `httpx` transport
95
-
96
-
Install the `httpx` extra and generate with the default transport mode:
97
-
98
-
```bash
99
-
uv add "openapi-python[httpx]"
100
-
uv run openapi-python generate --spec ./openapi.json --out ./generated --package my_client
101
-
```
102
-
103
-
You can supply preconfigured `httpx` clients:
104
-
105
-
```python
106
-
import httpx
107
-
108
-
from generated.my_client import AsyncClient, Client, DefaultAsyncTransport, DefaultTransport
0 commit comments