openapi-httpx-client 0.3.1__tar.gz → 0.4.1__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,131 @@
1
+ Metadata-Version: 2.1
2
+ Name: openapi-httpx-client
3
+ Version: 0.4.1
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
+ # OpenAPI Client for Python
17
+
18
+ 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.
19
+
20
+ ## Installation
21
+
22
+ ```bash
23
+ pip install openapi-httpx-client
24
+ ```
25
+
26
+ ## Usage
27
+
28
+ The client supports both synchronous and asynchronous usage patterns through a familiar context manager interface.
29
+
30
+ ### Asynchronous Usage
31
+
32
+ ```python
33
+ from openapiclient import OpenAPIClient
34
+ import asyncio
35
+
36
+ async def main():
37
+ # Initialize the API factory with the OpenAPI definition
38
+ api = OpenAPIClient(definition="https://petstore3.swagger.io/api/v3/openapi.json")
39
+
40
+ # Use the async client with context manager
41
+ async with api.AsyncClient() as client:
42
+ # Show available operations
43
+ print("Operations:", client.operations)
44
+ print("Available functions:", client.functions)
45
+
46
+ # Call operations directly as methods
47
+ pet = await client.getPetById(petId=1)
48
+ print(f"Status: {pet['status']}")
49
+ print(f"Pet data: {pet['data']}")
50
+
51
+ # Alternative way to call methods
52
+ pet = await client("getPetById", petId=2)
53
+ print(f"Another pet: {pet['data']}")
54
+
55
+ # Access AI tools definition for integration with LLMs
56
+ print(f"AI tools: {client.tools}")
57
+
58
+ if __name__ == "__main__":
59
+ asyncio.run(main())
60
+ ```
61
+
62
+ ### Synchronous Usage
63
+
64
+ ```python
65
+ from openapiclient import OpenAPIClient
66
+
67
+ # Initialize the API factory
68
+ api = OpenAPIClient(definition="https://petstore3.swagger.io/api/v3/openapi.json")
69
+
70
+ # Use the synchronous client with context manager
71
+ with api.Client() as client:
72
+ # Show available operations
73
+ print("Operations:", client.operations)
74
+
75
+ # Call operations directly
76
+ pet = client.getPetById(petId=1)
77
+ print(f"Pet name: {pet['data'].get('name')}")
78
+
79
+ # Call operations using dictionary-like access
80
+ store_inventory = client["getInventory"]()
81
+ print(f"Store inventory: {store_inventory['data']}")
82
+ ```
83
+
84
+ ### Advanced Options
85
+
86
+ You can pass any httpx client options when creating a client:
87
+
88
+ ```python
89
+ # With timeout and custom headers
90
+ with api.Client(timeout=30, headers={"API-Key": "your-api-key"}) as client:
91
+ result = client.someOperation()
92
+
93
+ # With proxy configuration
94
+ async with api.AsyncClient(proxies="http://localhost:8080") as client:
95
+ result = await client.someOperation()
96
+ ```
97
+
98
+ ## Features
99
+
100
+ - Intuitive API design similar to httpx with context managers
101
+ - Support for both synchronous and asynchronous operations
102
+ - Dynamic client generation using Python metaprogramming
103
+ - Compatible with OpenAPI 3.0 and 3.1 specifications
104
+ - Support for loading specifications from URL, file, or dictionary (JSON/YAML)
105
+ - Response format similar to axios (data, status, headers, config)
106
+ - AI tools generation for integration with LLMs and AI assistants
107
+
108
+ ## Client Properties
109
+
110
+ Each client instance provides these properties:
111
+
112
+ - `operations`: List of all available operation IDs
113
+ - `paths`: List of API paths defined in the specification
114
+ - `functions`: Dictionary of all operation methods mapped by name
115
+ - `tools`: List of AI function calling definitions for LLM integration
116
+
117
+ ## Response Format
118
+
119
+ All API responses are returned in a dictionary format with the following keys:
120
+
121
+ - `data`: The parsed response body (JSON or text)
122
+ - `status`: HTTP status code
123
+ - `headers`: Response headers
124
+ - `config`: Original request configuration
125
+
126
+ ## Author
127
+ lloydzhou
128
+
129
+
130
+
131
+
@@ -0,0 +1,114 @@
1
+ # OpenAPI Client for Python
2
+
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.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install openapi-httpx-client
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ The client supports both synchronous and asynchronous usage patterns through a familiar context manager interface.
14
+
15
+ ### Asynchronous Usage
16
+
17
+ ```python
18
+ from openapiclient import OpenAPIClient
19
+ import asyncio
20
+
21
+ async def main():
22
+ # Initialize the API factory with the OpenAPI definition
23
+ api = OpenAPIClient(definition="https://petstore3.swagger.io/api/v3/openapi.json")
24
+
25
+ # Use the async client with context manager
26
+ async with api.AsyncClient() as client:
27
+ # Show available operations
28
+ print("Operations:", client.operations)
29
+ print("Available functions:", client.functions)
30
+
31
+ # Call operations directly as methods
32
+ pet = await client.getPetById(petId=1)
33
+ print(f"Status: {pet['status']}")
34
+ print(f"Pet data: {pet['data']}")
35
+
36
+ # Alternative way to call methods
37
+ pet = await client("getPetById", petId=2)
38
+ print(f"Another pet: {pet['data']}")
39
+
40
+ # Access AI tools definition for integration with LLMs
41
+ print(f"AI tools: {client.tools}")
42
+
43
+ if __name__ == "__main__":
44
+ asyncio.run(main())
45
+ ```
46
+
47
+ ### Synchronous Usage
48
+
49
+ ```python
50
+ from openapiclient import OpenAPIClient
51
+
52
+ # Initialize the API factory
53
+ api = OpenAPIClient(definition="https://petstore3.swagger.io/api/v3/openapi.json")
54
+
55
+ # Use the synchronous client with context manager
56
+ with api.Client() as client:
57
+ # Show available operations
58
+ print("Operations:", client.operations)
59
+
60
+ # Call operations directly
61
+ pet = client.getPetById(petId=1)
62
+ print(f"Pet name: {pet['data'].get('name')}")
63
+
64
+ # Call operations using dictionary-like access
65
+ store_inventory = client["getInventory"]()
66
+ print(f"Store inventory: {store_inventory['data']}")
67
+ ```
68
+
69
+ ### Advanced Options
70
+
71
+ You can pass any httpx client options when creating a client:
72
+
73
+ ```python
74
+ # With timeout and custom headers
75
+ with api.Client(timeout=30, headers={"API-Key": "your-api-key"}) as client:
76
+ result = client.someOperation()
77
+
78
+ # With proxy configuration
79
+ async with api.AsyncClient(proxies="http://localhost:8080") as client:
80
+ result = await client.someOperation()
81
+ ```
82
+
83
+ ## Features
84
+
85
+ - Intuitive API design similar to httpx with context managers
86
+ - Support for both synchronous and asynchronous operations
87
+ - Dynamic client generation using Python metaprogramming
88
+ - Compatible with OpenAPI 3.0 and 3.1 specifications
89
+ - Support for loading specifications from URL, file, or dictionary (JSON/YAML)
90
+ - Response format similar to axios (data, status, headers, config)
91
+ - AI tools generation for integration with LLMs and AI assistants
92
+
93
+ ## Client Properties
94
+
95
+ Each client instance provides these properties:
96
+
97
+ - `operations`: List of all available operation IDs
98
+ - `paths`: List of API paths defined in the specification
99
+ - `functions`: Dictionary of all operation methods mapped by name
100
+ - `tools`: List of AI function calling definitions for LLM integration
101
+
102
+ ## Response Format
103
+
104
+ All API responses are returned in a dictionary format with the following keys:
105
+
106
+ - `data`: The parsed response body (JSON or text)
107
+ - `status`: HTTP status code
108
+ - `headers`: Response headers
109
+ - `config`: Original request configuration
110
+
111
+ ## Author
112
+ lloydzhou
113
+
114
+
@@ -0,0 +1,131 @@
1
+ Metadata-Version: 2.1
2
+ Name: openapi-httpx-client
3
+ Version: 0.4.1
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
+ # OpenAPI Client for Python
17
+
18
+ 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.
19
+
20
+ ## Installation
21
+
22
+ ```bash
23
+ pip install openapi-httpx-client
24
+ ```
25
+
26
+ ## Usage
27
+
28
+ The client supports both synchronous and asynchronous usage patterns through a familiar context manager interface.
29
+
30
+ ### Asynchronous Usage
31
+
32
+ ```python
33
+ from openapiclient import OpenAPIClient
34
+ import asyncio
35
+
36
+ async def main():
37
+ # Initialize the API factory with the OpenAPI definition
38
+ api = OpenAPIClient(definition="https://petstore3.swagger.io/api/v3/openapi.json")
39
+
40
+ # Use the async client with context manager
41
+ async with api.AsyncClient() as client:
42
+ # Show available operations
43
+ print("Operations:", client.operations)
44
+ print("Available functions:", client.functions)
45
+
46
+ # Call operations directly as methods
47
+ pet = await client.getPetById(petId=1)
48
+ print(f"Status: {pet['status']}")
49
+ print(f"Pet data: {pet['data']}")
50
+
51
+ # Alternative way to call methods
52
+ pet = await client("getPetById", petId=2)
53
+ print(f"Another pet: {pet['data']}")
54
+
55
+ # Access AI tools definition for integration with LLMs
56
+ print(f"AI tools: {client.tools}")
57
+
58
+ if __name__ == "__main__":
59
+ asyncio.run(main())
60
+ ```
61
+
62
+ ### Synchronous Usage
63
+
64
+ ```python
65
+ from openapiclient import OpenAPIClient
66
+
67
+ # Initialize the API factory
68
+ api = OpenAPIClient(definition="https://petstore3.swagger.io/api/v3/openapi.json")
69
+
70
+ # Use the synchronous client with context manager
71
+ with api.Client() as client:
72
+ # Show available operations
73
+ print("Operations:", client.operations)
74
+
75
+ # Call operations directly
76
+ pet = client.getPetById(petId=1)
77
+ print(f"Pet name: {pet['data'].get('name')}")
78
+
79
+ # Call operations using dictionary-like access
80
+ store_inventory = client["getInventory"]()
81
+ print(f"Store inventory: {store_inventory['data']}")
82
+ ```
83
+
84
+ ### Advanced Options
85
+
86
+ You can pass any httpx client options when creating a client:
87
+
88
+ ```python
89
+ # With timeout and custom headers
90
+ with api.Client(timeout=30, headers={"API-Key": "your-api-key"}) as client:
91
+ result = client.someOperation()
92
+
93
+ # With proxy configuration
94
+ async with api.AsyncClient(proxies="http://localhost:8080") as client:
95
+ result = await client.someOperation()
96
+ ```
97
+
98
+ ## Features
99
+
100
+ - Intuitive API design similar to httpx with context managers
101
+ - Support for both synchronous and asynchronous operations
102
+ - Dynamic client generation using Python metaprogramming
103
+ - Compatible with OpenAPI 3.0 and 3.1 specifications
104
+ - Support for loading specifications from URL, file, or dictionary (JSON/YAML)
105
+ - Response format similar to axios (data, status, headers, config)
106
+ - AI tools generation for integration with LLMs and AI assistants
107
+
108
+ ## Client Properties
109
+
110
+ Each client instance provides these properties:
111
+
112
+ - `operations`: List of all available operation IDs
113
+ - `paths`: List of API paths defined in the specification
114
+ - `functions`: Dictionary of all operation methods mapped by name
115
+ - `tools`: List of AI function calling definitions for LLM integration
116
+
117
+ ## Response Format
118
+
119
+ All API responses are returned in a dictionary format with the following keys:
120
+
121
+ - `data`: The parsed response body (JSON or text)
122
+ - `status`: HTTP status code
123
+ - `headers`: Response headers
124
+ - `config`: Original request configuration
125
+
126
+ ## Author
127
+ lloydzhou
128
+
129
+
130
+
131
+
@@ -1,3 +1,2 @@
1
1
  httpx>=0.23.0
2
2
  pyyaml>=6.0
3
- nanoid>=0.2.1