openapi-httpx-client 0.4.2__tar.gz → 0.5.0__tar.gz

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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Lloyd Zhou
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.
@@ -1,17 +1,21 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: openapi-httpx-client
3
- Version: 0.4.2
3
+ Version: 0.5.0
4
4
  Summary: A Python client for OpenAPI specifications using httpx
5
- Home-page: https://github.com/lloydzhou/openapiclient
6
- Author: lloydzhou
7
- Author-email: lloydzhou@qq.com
8
- License: UNKNOWN
9
- Platform: UNKNOWN
5
+ Author-email: lloydzhou <lloydzhou@qq.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/lloydzhou/openapiclient
8
+ Project-URL: Repository, https://github.com/lloydzhou/openapiclient
10
9
  Classifier: Programming Language :: Python :: 3
11
- Classifier: License :: OSI Approved :: MIT License
12
10
  Classifier: Operating System :: OS Independent
13
11
  Requires-Python: >=3.7
14
12
  Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: httpx>=0.23.0
15
+ Requires-Dist: pyyaml>=6.0
16
+ Provides-Extra: cli
17
+ Requires-Dist: click>=8.1; extra == "cli"
18
+ Dynamic: license-file
15
19
 
16
20
  # OpenAPI Client for Python
17
21
 
@@ -20,9 +24,39 @@ A Python implementation inspired by [openapi-client-axios](https://github.com/op
20
24
  ## Installation
21
25
 
22
26
  ```bash
23
- pip install openapi-httpx-client
27
+ pip install openapi-httpx-client # library only
28
+ pip install "openapi-httpx-client[cli]" # library + `oapi` command
24
29
  ```
25
30
 
31
+ ## CLI (`oapi`)
32
+
33
+ The optional `[cli]` extra installs an `oapi` command that turns any OpenAPI
34
+ spec into a CLI. Register an API once, then call its operations with generated
35
+ commands (parameter design follows the conventions of `gh` / `restish`):
36
+
37
+ ```bash
38
+ oapi connect petstore https://petstore3.swagger.io/api/v3/openapi.json
39
+ oapi ls # registered APIs
40
+ oapi schema petstore # list generated commands
41
+ oapi petstore get-pet-by-id 42 # required path params are positional
42
+ oapi petstore find-pets-by-status --status available
43
+ oapi petstore add-pet --body '{"name": "Rex", "photoUrls": []}'
44
+ oapi petstore add-pet -F name=Rex -F 'photoUrls=["https://x/r.png"]'
45
+ oapi api petstore GET /api/v3/store/inventory
46
+ ```
47
+
48
+ Conventions:
49
+
50
+ - operation command names are kebab-case (`getPetById` -> `get-pet-by-id`);
51
+ the raw `operationId` also works
52
+ - query/header parameters become `--kebab-case` flags; `enum` values are
53
+ validated (`--status [available|pending|sold]`)
54
+ - request body: `--body` (inline JSON / `@file` / `-` stdin) or repeated
55
+ `-F/--field key=value` (values parsed as JSON when possible)
56
+ - stdout carries data only; diagnostics go to stderr; non-2xx exits 1
57
+ - `--jq` filters output (`[].name`), `-o text` prints raw strings,
58
+ `--dry-run` prints the request without sending it
59
+
26
60
  ## Usage
27
61
 
28
62
  The client supports both synchronous and asynchronous usage patterns through a familiar context manager interface.
@@ -132,5 +166,3 @@ All API responses are returned in a dictionary format with the following keys:
132
166
  lloydzhou
133
167
 
134
168
 
135
-
136
-
@@ -1,18 +1,3 @@
1
- Metadata-Version: 2.1
2
- Name: openapi-httpx-client
3
- Version: 0.4.2
4
- Summary: A Python client for OpenAPI specifications using httpx
5
- Home-page: https://github.com/lloydzhou/openapiclient
6
- Author: lloydzhou
7
- Author-email: lloydzhou@qq.com
8
- License: UNKNOWN
9
- Platform: UNKNOWN
10
- Classifier: Programming Language :: Python :: 3
11
- Classifier: License :: OSI Approved :: MIT License
12
- Classifier: Operating System :: OS Independent
13
- Requires-Python: >=3.7
14
- Description-Content-Type: text/markdown
15
-
16
1
  # OpenAPI Client for Python
17
2
 
18
3
  A Python implementation inspired by [openapi-client-axios](https://github.com/openapistack/openapi-client-axios) that provides a dynamic client for OpenAPI specifications. This implementation uses httpx for HTTP requests and Python's metaprogramming capabilities to dynamically generate a client with an API design similar to httpx.
@@ -20,9 +5,39 @@ A Python implementation inspired by [openapi-client-axios](https://github.com/op
20
5
  ## Installation
21
6
 
22
7
  ```bash
23
- pip install openapi-httpx-client
8
+ pip install openapi-httpx-client # library only
9
+ pip install "openapi-httpx-client[cli]" # library + `oapi` command
10
+ ```
11
+
12
+ ## CLI (`oapi`)
13
+
14
+ The optional `[cli]` extra installs an `oapi` command that turns any OpenAPI
15
+ spec into a CLI. Register an API once, then call its operations with generated
16
+ commands (parameter design follows the conventions of `gh` / `restish`):
17
+
18
+ ```bash
19
+ oapi connect petstore https://petstore3.swagger.io/api/v3/openapi.json
20
+ oapi ls # registered APIs
21
+ oapi schema petstore # list generated commands
22
+ oapi petstore get-pet-by-id 42 # required path params are positional
23
+ oapi petstore find-pets-by-status --status available
24
+ oapi petstore add-pet --body '{"name": "Rex", "photoUrls": []}'
25
+ oapi petstore add-pet -F name=Rex -F 'photoUrls=["https://x/r.png"]'
26
+ oapi api petstore GET /api/v3/store/inventory
24
27
  ```
25
28
 
29
+ Conventions:
30
+
31
+ - operation command names are kebab-case (`getPetById` -> `get-pet-by-id`);
32
+ the raw `operationId` also works
33
+ - query/header parameters become `--kebab-case` flags; `enum` values are
34
+ validated (`--status [available|pending|sold]`)
35
+ - request body: `--body` (inline JSON / `@file` / `-` stdin) or repeated
36
+ `-F/--field key=value` (values parsed as JSON when possible)
37
+ - stdout carries data only; diagnostics go to stderr; non-2xx exits 1
38
+ - `--jq` filters output (`[].name`), `-o text` prints raw strings,
39
+ `--dry-run` prints the request without sending it
40
+
26
41
  ## Usage
27
42
 
28
43
  The client supports both synchronous and asynchronous usage patterns through a familiar context manager interface.
@@ -132,5 +147,3 @@ All API responses are returned in a dictionary format with the following keys:
132
147
  lloydzhou
133
148
 
134
149
 
135
-
136
-
@@ -1,3 +1,22 @@
1
+ Metadata-Version: 2.4
2
+ Name: openapi-httpx-client
3
+ Version: 0.5.0
4
+ Summary: A Python client for OpenAPI specifications using httpx
5
+ Author-email: lloydzhou <lloydzhou@qq.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/lloydzhou/openapiclient
8
+ Project-URL: Repository, https://github.com/lloydzhou/openapiclient
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.7
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: httpx>=0.23.0
15
+ Requires-Dist: pyyaml>=6.0
16
+ Provides-Extra: cli
17
+ Requires-Dist: click>=8.1; extra == "cli"
18
+ Dynamic: license-file
19
+
1
20
  # OpenAPI Client for Python
2
21
 
3
22
  A Python implementation inspired by [openapi-client-axios](https://github.com/openapistack/openapi-client-axios) that provides a dynamic client for OpenAPI specifications. This implementation uses httpx for HTTP requests and Python's metaprogramming capabilities to dynamically generate a client with an API design similar to httpx.
@@ -5,9 +24,39 @@ A Python implementation inspired by [openapi-client-axios](https://github.com/op
5
24
  ## Installation
6
25
 
7
26
  ```bash
8
- pip install openapi-httpx-client
27
+ pip install openapi-httpx-client # library only
28
+ pip install "openapi-httpx-client[cli]" # library + `oapi` command
9
29
  ```
10
30
 
31
+ ## CLI (`oapi`)
32
+
33
+ The optional `[cli]` extra installs an `oapi` command that turns any OpenAPI
34
+ spec into a CLI. Register an API once, then call its operations with generated
35
+ commands (parameter design follows the conventions of `gh` / `restish`):
36
+
37
+ ```bash
38
+ oapi connect petstore https://petstore3.swagger.io/api/v3/openapi.json
39
+ oapi ls # registered APIs
40
+ oapi schema petstore # list generated commands
41
+ oapi petstore get-pet-by-id 42 # required path params are positional
42
+ oapi petstore find-pets-by-status --status available
43
+ oapi petstore add-pet --body '{"name": "Rex", "photoUrls": []}'
44
+ oapi petstore add-pet -F name=Rex -F 'photoUrls=["https://x/r.png"]'
45
+ oapi api petstore GET /api/v3/store/inventory
46
+ ```
47
+
48
+ Conventions:
49
+
50
+ - operation command names are kebab-case (`getPetById` -> `get-pet-by-id`);
51
+ the raw `operationId` also works
52
+ - query/header parameters become `--kebab-case` flags; `enum` values are
53
+ validated (`--status [available|pending|sold]`)
54
+ - request body: `--body` (inline JSON / `@file` / `-` stdin) or repeated
55
+ `-F/--field key=value` (values parsed as JSON when possible)
56
+ - stdout carries data only; diagnostics go to stderr; non-2xx exits 1
57
+ - `--jq` filters output (`[].name`), `-o text` prints raw strings,
58
+ `--dry-run` prints the request without sending it
59
+
11
60
  ## Usage
12
61
 
13
62
  The client supports both synchronous and asynchronous usage patterns through a familiar context manager interface.
@@ -1,9 +1,14 @@
1
+ LICENSE
1
2
  README.md
2
- setup.py
3
+ pyproject.toml
3
4
  openapi_httpx_client.egg-info/PKG-INFO
4
5
  openapi_httpx_client.egg-info/SOURCES.txt
5
6
  openapi_httpx_client.egg-info/dependency_links.txt
7
+ openapi_httpx_client.egg-info/entry_points.txt
6
8
  openapi_httpx_client.egg-info/requires.txt
7
9
  openapi_httpx_client.egg-info/top_level.txt
8
10
  openapiclient/__init__.py
9
- openapiclient/client.py
11
+ openapiclient/cli.py
12
+ openapiclient/client.py
13
+ tests/test_cli.py
14
+ tests/test_client.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ oapi = openapiclient.cli:main
@@ -1,2 +1,5 @@
1
1
  httpx>=0.23.0
2
2
  pyyaml>=6.0
3
+
4
+ [cli]
5
+ click>=8.1