openapi-httpx-client 0.4.3__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.
@@ -1,28 +1,21 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: openapi-httpx-client
3
- Version: 0.4.3
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
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
8
9
  Classifier: Programming Language :: Python :: 3
9
- Classifier: License :: OSI Approved :: MIT License
10
10
  Classifier: Operating System :: OS Independent
11
11
  Requires-Python: >=3.7
12
12
  Description-Content-Type: text/markdown
13
13
  License-File: LICENSE
14
14
  Requires-Dist: httpx>=0.23.0
15
15
  Requires-Dist: pyyaml>=6.0
16
- Dynamic: author
17
- Dynamic: author-email
18
- Dynamic: classifier
19
- Dynamic: description
20
- Dynamic: description-content-type
21
- Dynamic: home-page
16
+ Provides-Extra: cli
17
+ Requires-Dist: click>=8.1; extra == "cli"
22
18
  Dynamic: license-file
23
- Dynamic: requires-dist
24
- Dynamic: requires-python
25
- Dynamic: summary
26
19
 
27
20
  # OpenAPI Client for Python
28
21
 
@@ -31,9 +24,39 @@ A Python implementation inspired by [openapi-client-axios](https://github.com/op
31
24
  ## Installation
32
25
 
33
26
  ```bash
34
- pip install openapi-httpx-client
27
+ pip install openapi-httpx-client # library only
28
+ pip install "openapi-httpx-client[cli]" # library + `oapi` command
35
29
  ```
36
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
+
37
60
  ## Usage
38
61
 
39
62
  The client supports both synchronous and asynchronous usage patterns through a familiar context manager interface.
@@ -1,29 +1,3 @@
1
- Metadata-Version: 2.4
2
- Name: openapi-httpx-client
3
- Version: 0.4.3
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
- Classifier: Programming Language :: Python :: 3
9
- Classifier: License :: OSI Approved :: MIT License
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
- Dynamic: author
17
- Dynamic: author-email
18
- Dynamic: classifier
19
- Dynamic: description
20
- Dynamic: description-content-type
21
- Dynamic: home-page
22
- Dynamic: license-file
23
- Dynamic: requires-dist
24
- Dynamic: requires-python
25
- Dynamic: summary
26
-
27
1
  # OpenAPI Client for Python
28
2
 
29
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.
@@ -31,9 +5,39 @@ A Python implementation inspired by [openapi-client-axios](https://github.com/op
31
5
  ## Installation
32
6
 
33
7
  ```bash
34
- pip install openapi-httpx-client
8
+ pip install openapi-httpx-client # library only
9
+ pip install "openapi-httpx-client[cli]" # library + `oapi` command
35
10
  ```
36
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
27
+ ```
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
+
37
41
  ## Usage
38
42
 
39
43
  The client supports both synchronous and asynchronous usage patterns through a familiar context manager interface.
@@ -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,10 +1,14 @@
1
1
  LICENSE
2
2
  README.md
3
- setup.py
3
+ pyproject.toml
4
4
  openapi_httpx_client.egg-info/PKG-INFO
5
5
  openapi_httpx_client.egg-info/SOURCES.txt
6
6
  openapi_httpx_client.egg-info/dependency_links.txt
7
+ openapi_httpx_client.egg-info/entry_points.txt
7
8
  openapi_httpx_client.egg-info/requires.txt
8
9
  openapi_httpx_client.egg-info/top_level.txt
9
10
  openapiclient/__init__.py
10
- 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