@hey-api/openapi-python 0.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Hey API
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,411 @@
1
+ <div align="center">
2
+ <img alt="Hey API presents openapi-python" height="214" src="https://heyapi.dev/assets/.gen/openapi-python-hero-640w.png" width="438">
3
+ <h1><b>OpenAPI Python</b></h1>
4
+ <p><em>“The ecosystem trusted by TypeScript developers is coming to Python codebases.”</em><br/><sub>— Lubos, Founder of Hey API</sub></p>
5
+ </div>
6
+
7
+ <p align="center">
8
+ <!-- <a href="https://www.devtrends.dev/trends?c=v1.kZIBIg"><img src="https://api.devtrends.dev/badge/npm/%40hey-api%2Fopenapi-python?period=month&style=flat&view=value" alt="DevTrends badge for @hey-api/openapi-python" /></a> -->
9
+ <!-- <a href="https://www.devtrends.dev/trends?c=v1.kZIBIg&v=change"><img src="https://api.devtrends.dev/badge/npm/%40hey-api%2Fopenapi-python?period=year&style=flat&view=change" alt="DevTrends badge for @hey-api/openapi-python" /></a> -->
10
+ <a href="https://github.com/hey-api/hey-api/actions?query=branch%3Amain"><img src="https://github.com/hey-api/hey-api/actions/workflows/ci.yml/badge.svg?event=push&branch=main" alt="CI status" /></a>
11
+ <a href="https://github.com/hey-api/hey-api"><img src="https://img.shields.io/github/stars/hey-api/hey-api?style=flat&logo=github&label=GitHub&color=54C82D" alt="GitHub stars" /></a>
12
+ <a href="https://github.com/hey-api/hey-api/blob/main/LICENSE.md"><img src="https://img.shields.io/github/license/hey-api/hey-api" alt="MIT License"></a>
13
+ </p>
14
+
15
+ <p align="center">
16
+ <!-- <a href="https://stackblitz.com/edit/hey-api-example?file=openapi-ts.config.ts,src%2Fclient%2Fschemas.gen.ts,src%2Fclient%2Fsdk.gen.ts,src%2Fclient%2Ftypes.gen.ts">Demo</a>
17
+ <span>&nbsp;•&nbsp;</span> -->
18
+ <a href="https://heyapi.dev/docs/openapi/python/get-started">Manual</a>
19
+ <span>&nbsp;•&nbsp;</span>
20
+ <a href="https://github.com/hey-api/hey-api/issues">Issues</a>
21
+ <span>&nbsp;•&nbsp;</span>
22
+ <a href="https://heyapi.dev/docs/openapi/typescript/community/contributing">Contribute</a>
23
+ </p>
24
+
25
+ ## About
26
+
27
+ The OpenAPI to Python code generator.
28
+
29
+ Generate production-grade SDKs and Pydantic models.
30
+
31
+ Part of the Hey API ecosystem.
32
+
33
+ ## Features
34
+
35
+ - production-grade code that compiles
36
+ - runs in any Node.js 22+ environment
37
+ - accepts any OpenAPI specification
38
+ - core plugin for SDKs
39
+ - HTTP client for HTTPX
40
+ - highly customizable via plugins
41
+ - [sync with Hey API Registry](https://heyapi.dev/docs/openapi/typescript/integrations) for spec management
42
+ <!-- - 20+ plugins to reduce third-party boilerplate -->
43
+
44
+ <!-- template-contributing-start -->
45
+
46
+ ## Contributing
47
+
48
+ Want to see your code in products used by millions?
49
+
50
+ Start with our [Contributing](https://heyapi.dev/docs/openapi/typescript/community/contributing) guide and release your first feature.
51
+
52
+ <!-- template-contributing-end -->
53
+
54
+ <!-- template-sponsors-start -->
55
+
56
+ ## Sponsors
57
+
58
+ Partners behind the future of API tooling. [Become a sponsor](https://github.com/sponsors/hey-api).
59
+
60
+ <h3 align="center">Gold</h3>
61
+
62
+ <table align="center" style="justify-content: center;align-items: center;display: flex;">
63
+ <tbody>
64
+ <tr>
65
+ <td align="center" width="336px">
66
+ <p></p>
67
+ <p>
68
+ <a href="https://kutt.to/pkEZyc" target="_blank">
69
+ <picture height="50px">
70
+ <source media="(prefers-color-scheme: dark)" srcset="https://heyapi.dev/assets/.gen/stainless-logo-wordmark-480w.jpeg">
71
+ <img alt="Stainless logo" height="50px" src="https://heyapi.dev/assets/.gen/stainless-logo-wordmark-480w.jpeg">
72
+ </picture>
73
+ </a>
74
+ <br/>
75
+ Best-in-class developer interfaces for your API.
76
+ <br/>
77
+ <a href="https://kutt.to/pkEZyc" style="text-decoration:none;" target="_blank">
78
+ stainless.com
79
+ </a>
80
+ </p>
81
+ <p></p>
82
+ </td>
83
+ <td align="center" width="336px">
84
+ <p></p>
85
+ <p>
86
+ <a href="https://kutt.to/QM9Q2N" target="_blank">
87
+ <picture height="50px">
88
+ <source media="(prefers-color-scheme: dark)" srcset="https://heyapi.dev/assets/opencode/logo-light.svg">
89
+ <img alt="Opencode logo" height="50px" src="https://heyapi.dev/assets/opencode/logo-dark.svg">
90
+ </picture>
91
+ </a>
92
+ <br/>
93
+ The open source coding agent.
94
+ <br/>
95
+ <a href="https://kutt.to/QM9Q2N" style="text-decoration:none;" target="_blank">
96
+ opencode.ai
97
+ </a>
98
+ </p>
99
+ <p></p>
100
+ </td>
101
+ </tr>
102
+ </tbody>
103
+ </table>
104
+
105
+ <h3 align="center">Silver</h3>
106
+
107
+ <table align="center" style="justify-content: center;align-items: center;display: flex;">
108
+ <tbody>
109
+ <tr>
110
+ <td align="center" width="172px">
111
+ <a href="https://kutt.to/skQUVd" target="_blank">
112
+ <picture height="40px">
113
+ <source media="(prefers-color-scheme: dark)" srcset="https://heyapi.dev/assets/scalar/logo-light.svg">
114
+ <img alt="Scalar logo" height="40px" src="https://heyapi.dev/assets/scalar/logo-dark.svg">
115
+ </picture>
116
+ </a>
117
+ <br/>
118
+ <a href="https://kutt.to/skQUVd" style="text-decoration:none;" target="_blank">
119
+ scalar.com
120
+ </a>
121
+ </td>
122
+ <td align="center" width="172px">
123
+ <a href="https://kutt.to/Dr9GuW" target="_blank">
124
+ <picture height="40px">
125
+ <source media="(prefers-color-scheme: dark)" srcset="https://heyapi.dev/assets/fastapi/logo-light.svg">
126
+ <img alt="FastAPI logo" height="40px" src="https://heyapi.dev/assets/fastapi/logo-dark.svg">
127
+ </picture>
128
+ </a>
129
+ <br/>
130
+ <a href="https://kutt.to/Dr9GuW" style="text-decoration:none;" target="_blank">
131
+ fastapi.tiangolo.com
132
+ </a>
133
+ </td>
134
+ <td align="center" width="172px">
135
+ <a href="https://kutt.to/yZVkdV" target="_blank">
136
+ <picture height="40px">
137
+ <source media="(prefers-color-scheme: dark)" srcset="https://heyapi.dev/assets/brands/unblocked/logo-light.svg">
138
+ <img alt="Unblocked logo" height="40px" src="https://heyapi.dev/assets/brands/unblocked/logo-dark.svg">
139
+ </picture>
140
+ </a>
141
+ <br/>
142
+ <a href="https://kutt.to/yZVkdV" style="text-decoration:none;" target="_blank">
143
+ getunblocked.com
144
+ </a>
145
+ </td>
146
+ </tr>
147
+ </tbody>
148
+ </table>
149
+
150
+ <h3 align="center">Bronze</h3>
151
+
152
+ <table align="center" style="justify-content: center;align-items: center;display: flex;">
153
+ <tbody>
154
+ <tr>
155
+ <td align="center" width="136px">
156
+ <a href="https://kutt.to/YpaKsX" target="_blank">
157
+ <picture height="34px">
158
+ <source media="(prefers-color-scheme: dark)" srcset="https://heyapi.dev/assets/.gen/kinde-logo-wordmark-dark-480w.webp">
159
+ <img alt="Kinde logo" height="34px" src="https://heyapi.dev/assets/.gen/kinde-logo-wordmark-480w.jpeg">
160
+ </picture>
161
+ </a>
162
+ </td>
163
+ <td align="center" width="136px">
164
+ <a href="https://kutt.to/KkqSaw" target="_blank">
165
+ <picture height="34px">
166
+ <source media="(prefers-color-scheme: dark)" srcset="https://heyapi.dev/assets/cella/logo-light.svg">
167
+ <img alt="Cella logo" height="34px" src="https://heyapi.dev/assets/cella/logo-dark.svg">
168
+ </picture>
169
+ </a>
170
+ </td>
171
+ <td align="center" width="136px">
172
+ <a href="https://kutt.to/HW4GYR" target="_blank">
173
+ <picture height="34px">
174
+ <source media="(prefers-color-scheme: dark)" srcset="https://heyapi.dev/assets/photon/logo-light.svg">
175
+ <img alt="Photon logo" height="34px" src="https://heyapi.dev/assets/photon/logo-dark.svg">
176
+ </picture>
177
+ </a>
178
+ </td>
179
+ </tr>
180
+ </tbody>
181
+ </table>
182
+ <!-- template-sponsors-end -->
183
+
184
+ ## Quick Start
185
+
186
+ The fastest way to use `@hey-api/openapi-python` is via npx
187
+
188
+ ```sh
189
+ npx @hey-api/openapi-python -i hey-api/backend -o src/client
190
+ ```
191
+
192
+ Congratulations on creating your first client! 🎉 You can learn more about the generated files on the [Output](https://heyapi.dev/docs/openapi/python/output) page.
193
+
194
+ ## Installation
195
+
196
+ You can download `@hey-api/openapi-python` from npm using your favorite package manager.
197
+
198
+ #### npm
199
+
200
+ ```sh
201
+ npm install @hey-api/openapi-python -D -E
202
+ ```
203
+
204
+ #### pnpm
205
+
206
+ ```sh
207
+ pnpm add @hey-api/openapi-python -D -E
208
+ ```
209
+
210
+ #### yarn
211
+
212
+ ```sh
213
+ yarn add @hey-api/openapi-python -D -E
214
+ ```
215
+
216
+ #### bun
217
+
218
+ ```sh
219
+ bun add @hey-api/openapi-python -D
220
+ ```
221
+
222
+ ### Versioning
223
+
224
+ This package is in [initial development](https://semver.org/#spec-item-4). Please pin an exact version so you can safely upgrade when you're ready.
225
+
226
+ We publish [migration notes](https://heyapi.dev/docs/openapi/python/migrating) for every breaking release. You might not be impacted by a breaking change if you don't use the affected features.
227
+
228
+ ## Usage
229
+
230
+ ### CLI
231
+
232
+ Most people run `@hey-api/openapi-python` via CLI. To do that, add a script to your `package.json` file which will make `openapi-python` executable through script.
233
+
234
+ ```json
235
+ "scripts": {
236
+ "openapi-python": "openapi-python"
237
+ }
238
+ ```
239
+
240
+ The above script can be executed by running `npm run openapi-python` or equivalent command in other package managers. Next, we will create a [configuration](https://heyapi.dev/docs/openapi/python/configuration) file and move our options from Quick Start to it.
241
+
242
+ ### Node.js
243
+
244
+ You can also generate output programmatically by calling `createClient()` in a JavaScript/TypeScript file.
245
+
246
+ #### `script.ts`
247
+
248
+ ```ts
249
+ import { createClient } from '@hey-api/openapi-python';
250
+
251
+ createClient({
252
+ input: 'hey-api/backend', // sign up at app.heyapi.dev
253
+ output: 'src/client',
254
+ });
255
+ ```
256
+
257
+ <!-- ### Vite
258
+
259
+ If you're using [Vite](https://vite.dev), you can integrate `@hey-api/openapi-python` directly into your build pipeline with `@hey-api/vite-plugin`. Install it alongside the main package:
260
+
261
+ #### npm
262
+
263
+ ```sh
264
+ npm install @hey-api/vite-plugin -D -E
265
+ ```
266
+
267
+ #### pnpm
268
+
269
+ ```sh
270
+ pnpm add @hey-api/vite-plugin -D -E
271
+ ```
272
+
273
+ #### yarn
274
+
275
+ ```sh
276
+ yarn add @hey-api/vite-plugin -D -E
277
+ ```
278
+
279
+ #### bun
280
+
281
+ ```sh
282
+ bun add @hey-api/vite-plugin -D
283
+ ```
284
+
285
+ Then add the plugin to your Vite configuration:
286
+
287
+ #### `vite.config.ts`
288
+
289
+ ```ts
290
+ import { heyApiPlugin } from '@hey-api/vite-plugin';
291
+ import { defineConfig } from 'vite';
292
+
293
+ export default defineConfig({
294
+ plugins: [
295
+ heyApiPlugin({
296
+ config: {
297
+ input: 'hey-api/backend', // sign up at app.heyapi.dev
298
+ output: 'src/client',
299
+ },
300
+ }),
301
+ ],
302
+ });
303
+ ```
304
+
305
+ See the [Vite](https://heyapi.dev/docs/openapi/typescript/configuration/vite) page for full configuration options. -->
306
+
307
+ ## Configuration
308
+
309
+ `@hey-api/openapi-python` supports loading configuration from any file inside your project root folder supported by [jiti loader](https://github.com/unjs/c12?tab=readme-ov-file#-features). Below are the most common file formats.
310
+
311
+ #### `openapi-python.config.ts`
312
+
313
+ ```js
314
+ import { defineConfig } from '@hey-api/openapi-python';
315
+
316
+ export default defineConfig({
317
+ input: 'hey-api/backend', // sign up at app.heyapi.dev
318
+ output: 'src/client',
319
+ });
320
+ ```
321
+
322
+ #### `openapi-python.config.cjs`
323
+
324
+ ```js
325
+ /** @type {import('@hey-api/openapi-python').UserConfig} */
326
+ module.exports = {
327
+ input: 'hey-api/backend', // sign up at app.heyapi.dev
328
+ output: 'src/client',
329
+ };
330
+ ```
331
+
332
+ #### `openapi-python.config.mjs`
333
+
334
+ ```js
335
+ /** @type {import('@hey-api/openapi-python').UserConfig} */
336
+ export default {
337
+ input: 'hey-api/backend', // sign up at app.heyapi.dev
338
+ output: 'src/client',
339
+ };
340
+ ```
341
+
342
+ Alternatively, you can use `openapi-python.config.js` and configure the export statement depending on your project setup.
343
+
344
+ ### Input
345
+
346
+ You must set the input so we can load your OpenAPI specification. It can be a path or URL, object containing a path or URL, or an object representing an OpenAPI specification. Hey API supports all valid OpenAPI versions and file formats.
347
+
348
+ > If you use an HTTPS URL with a self-signed certificate in development, you will need to set [`NODE_TLS_REJECT_UNAUTHORIZED=0`](https://github.com/hey-api/hey-api/issues/276#issuecomment-2043143501) in your environment.
349
+
350
+ ### Output
351
+
352
+ You must set the output so we know where to generate your files. It can be a path to the destination folder or an object containing the destination folder path and optional settings.
353
+
354
+ > You should treat the output folder as a dependency. Do not directly modify its contents as your changes might be erased when you run `@hey-api/openapi-python` again.
355
+
356
+ ## Parser
357
+
358
+ We parse your input before making it available to plugins. While configuring the parser is optional, it's the perfect place to modify or validate your input if needed.
359
+
360
+ ## Plugins
361
+
362
+ Plugins are responsible for generating artifacts from your input. By default, Hey API will generate Pydantic models and SDK from your OpenAPI specification. You can add, remove, or customize any of the plugins. In fact, we highly encourage you to do so!
363
+
364
+ ### Client
365
+
366
+ Clients are responsible for sending the actual HTTP requests. We default to HTTPX client if you're generating SDKs, but you can choose a different option from the available clients.
367
+
368
+ ### Available Clients
369
+
370
+ - [`@hey-api/client-httpx`](https://heyapi.dev/docs/openapi/python/clients/httpx)
371
+
372
+ ### Proposed Clients (Vote to Prioritize)
373
+
374
+ The following clients are roadmap proposals and are not started yet. You can help us prioritize them by voting on [GitHub](https://github.com/hey-api/hey-api/issues?q=state%3Aopen%20label%3A%22vote%20%F0%9F%93%A9%22).
375
+
376
+ - [`@hey-api/client-aiohttp`](https://heyapi.dev/docs/openapi/python/clients/aiohttp)
377
+ - [`@hey-api/client-requests`](https://heyapi.dev/docs/openapi/python/clients/requests)
378
+ - [`@hey-api/client-urllib3`](https://heyapi.dev/docs/openapi/python/clients/urllib3)
379
+
380
+ Don't see your client? [Build your own](https://heyapi.dev/docs/openapi/python/clients/custom) or let us know your interest by [opening an issue](https://github.com/hey-api/hey-api/issues).
381
+
382
+ ### Available Plugins
383
+
384
+ These plugins help reduce boilerplate associated with third-party dependencies. Hey API natively supports the most popular packages. Please open an issue on [GitHub](https://github.com/hey-api/hey-api/issues) if you'd like us to support your favorite package.
385
+
386
+ - [`pydantic`](https://heyapi.dev/docs/openapi/python/plugins/pydantic)
387
+
388
+ ### Proposed Plugins (Vote to Prioritize)
389
+
390
+ The following plugins are roadmap proposals and are not started yet. You can help us prioritize them by voting on [GitHub](https://github.com/hey-api/hey-api/issues?q=state%3Aopen%20label%3A%22vote%20%F0%9F%93%A9%22).
391
+
392
+ - [Attrs](https://heyapi.dev/docs/openapi/python/plugins/attrs)
393
+ - [Dataclasses](https://heyapi.dev/docs/openapi/python/plugins/dataclasses)
394
+ - [Factory Boy](https://heyapi.dev/docs/openapi/python/plugins/factory-boy)
395
+ - [Faker](https://heyapi.dev/docs/openapi/python/plugins/faker)
396
+ - [Marshmallow](https://heyapi.dev/docs/openapi/python/plugins/marshmallow)
397
+ - [Mimesis](https://heyapi.dev/docs/openapi/python/plugins/mimesis)
398
+
399
+ Don't see your plugin? [Build your own](https://heyapi.dev/docs/openapi/python/plugins/custom) or let us know your interest by [opening an issue](https://github.com/hey-api/hey-api/issues).
400
+
401
+ ## Migrating
402
+
403
+ You can learn more on the [Migrating](https://heyapi.dev/docs/openapi/python/migrating) page.
404
+
405
+ <!-- template-license-start -->
406
+
407
+ ## License
408
+
409
+ Released under the [MIT License](https://github.com/hey-api/hey-api/blob/main/LICENSE.md).
410
+
411
+ <!-- template-license-end -->
package/bin/run.cmd ADDED
@@ -0,0 +1,3 @@
1
+ @echo off
2
+ node "%~dp0\run.js" %*
3
+
package/bin/run.js ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env node
2
+ import { spawnSync } from 'node:child_process';
3
+ import fs from 'node:fs';
4
+ import path from 'node:path';
5
+ import { fileURLToPath } from 'node:url';
6
+
7
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
8
+ const target = path.join(__dirname, '..', 'dist', 'run.mjs');
9
+
10
+ if (!fs.existsSync(target)) {
11
+ console.error('openapi-python not built (expect dist/run.mjs)');
12
+ process.exit(1);
13
+ }
14
+
15
+ const res = spawnSync(process.execPath, [target, ...process.argv.slice(2)], {
16
+ stdio: 'inherit',
17
+ });
18
+ process.exit(res.status ?? 0);
@@ -0,0 +1,15 @@
1
+ import { createRequire } from "node:module";
2
+ //#region \0rolldown/runtime.js
3
+ var __defProp = Object.defineProperty;
4
+ var __exportAll = (all, no_symbols) => {
5
+ let target = {};
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: true
9
+ });
10
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
11
+ return target;
12
+ };
13
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
14
+ //#endregion
15
+ export { __require as n, __exportAll as t };
@@ -0,0 +1,3 @@
1
+ from .client import Client, build_client_params, create_client
2
+
3
+ __all__ = ["Client", "build_client_params", "create_client"]
@@ -0,0 +1,128 @@
1
+ from typing import Any, Optional
2
+ import httpx
3
+
4
+
5
+ EXTRA_PREFIXES_MAP = {
6
+ "$body_": "json",
7
+ "$headers_": "headers",
8
+ "$path_": "path",
9
+ "$query_": "params",
10
+ }
11
+
12
+
13
+ def build_client_params(fields: list[dict[str, Any]], **kwargs) -> dict[str, Any]:
14
+ """Build client parameters from flat keyword arguments.
15
+
16
+ Args:
17
+ fields: List of field configurations with 'in', 'key', and optional 'map'.
18
+ **kwargs: Flat parameters passed to the SDK method.
19
+
20
+ Returns:
21
+ Dict suitable for httpx client methods: {params: {...}, headers: {...}, json: Any}
22
+ """
23
+ result: dict[str, Any] = {}
24
+
25
+ key_map = {}
26
+ for field in fields:
27
+ key = field.get("key")
28
+ if key:
29
+ key_map[key] = {
30
+ "in": field.get("in"),
31
+ "map": field.get("map", key),
32
+ }
33
+
34
+ for key, value in kwargs.items():
35
+ if value is None:
36
+ continue
37
+
38
+ field = key_map.get(key)
39
+
40
+ if field:
41
+ in_slot = field["in"]
42
+ map_key = field["map"]
43
+ slot = "json" if in_slot == "body" else in_slot
44
+
45
+ if in_slot == "body":
46
+ result[slot] = value
47
+ else:
48
+ if slot not in result:
49
+ result[slot] = {}
50
+ result[slot][map_key] = value
51
+ else:
52
+ for prefix, slot in EXTRA_PREFIXES_MAP.items():
53
+ if key.startswith(prefix):
54
+ actual_key = key[len(prefix) :]
55
+ if slot not in result:
56
+ result[slot] = {}
57
+ result[slot][actual_key] = value
58
+ break
59
+ else:
60
+ if "params" not in result:
61
+ result["params"] = {}
62
+ result["params"][key] = value
63
+
64
+ for slot in list(result.keys()):
65
+ if not result[slot]:
66
+ del result[slot]
67
+
68
+ return result
69
+
70
+
71
+ class BaseClient:
72
+ """Base HTTP client using httpx that SDK classes extend."""
73
+
74
+ def __init__(self, client: Optional[httpx.Client] = None, base_url: Optional[str] = None, **kwargs):
75
+ if client is not None:
76
+ self._client = client
77
+ else:
78
+ self._client = httpx.Client(base_url=base_url or "", **kwargs)
79
+
80
+ @property
81
+ def client(self) -> httpx.Client:
82
+ """Get the httpx client instance."""
83
+ return self._client
84
+
85
+ def request(self, method: str, url: str, **kwargs) -> httpx.Response:
86
+ """Make an HTTP request."""
87
+ return self._client.request(method, url, **kwargs)
88
+
89
+ def get(self, url: str, **kwargs) -> httpx.Response:
90
+ """Make a GET request."""
91
+ return self._client.get(url, **kwargs)
92
+
93
+ def post(self, url: str, **kwargs) -> httpx.Response:
94
+ """Make a POST request."""
95
+ return self._client.post(url, **kwargs)
96
+
97
+ def put(self, url: str, **kwargs) -> httpx.Response:
98
+ """Make a PUT request."""
99
+ return self._client.put(url, **kwargs)
100
+
101
+ def patch(self, url: str, **kwargs) -> httpx.Response:
102
+ """Make a PATCH request."""
103
+ return self._client.patch(url, **kwargs)
104
+
105
+ def delete(self, url: str, **kwargs) -> httpx.Response:
106
+ """Make a DELETE request."""
107
+ return self._client.delete(url, **kwargs)
108
+
109
+ def close(self):
110
+ """Close the client."""
111
+ self._client.close()
112
+
113
+ def __enter__(self):
114
+ return self
115
+
116
+ def __exit__(self, *args):
117
+ self.close()
118
+
119
+
120
+ class Client(BaseClient):
121
+ """HTTP client using httpx (alias for BaseClient)."""
122
+
123
+ pass
124
+
125
+
126
+ def create_client(base_url: Optional[str] = None, **kwargs) -> Client:
127
+ """Create a new HTTP client instance."""
128
+ return Client(base_url=base_url, **kwargs)