Metadata-Version: 2.4
Name: openapi-dynamic-client
Version: 0.1.0
Summary: Generic dynamic Python client for APIs described by OpenAPI specifications.
Author: Luís Filipe Esperança de Abreu
License: MIT License
        
        Copyright (c) 2026 Luís Filipe Esperança de Abreu
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the Software), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
Project-URL: Homepage, https://github.com/lfeabreu/openapiclient-lib
Project-URL: Repository, https://github.com/lfeabreu/openapiclient-lib
Project-URL: Issues, https://github.com/lfeabreu/openapiclient-lib/issues
Keywords: openapi,swagger,api-client,http-client,dynamic-client
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: httpx>=0.27.0
Dynamic: license-file

# openapi-dynamic-client

Generic dynamic Python client for APIs described by OpenAPI specifications.

This package allows you to consume REST APIs from an OpenAPI/Swagger JSON file without generating static client code.

## Features

- Dynamic operation discovery from OpenAPI
- Call endpoints by `operationId`
- Optional tag-scoped access through module proxies
- Automatic pagination helper
- JSON and CSV response support
- Works with local OpenAPI files or Python dictionaries

## Installation

```bash
pip install openapi-dynamic-client
```

For local development:

```bash
git clone https://github.com/lfeabreu/openapiclient-lib.git
cd openapiclient-lib
pip install -e .
```

## Basic Usage

```python
from openapiclient import OpenAPIClient

api = OpenAPIClient.from_file("api-docs.json")

response = api.call(
    "listUsers",
    page=1,
)

print(response)
```

## Listing operations

```python
operations = api.list_operations()

for operation in operations:
    print(operation)
```

## Calling operations by tag

```python
users = api.module("users")

response = users.listUsers(page=1)
print(response)
```

## Pagination

For APIs that return paginated responses with fields such as `resultado`, `totalPaginas`, and `paginasRestantes`:

```python
for item in api.items("listUsers", max_pages=1):
    print(item)
```

Using a tag/module proxy:

```python
users = api.module("users")

for item in users.items("listUsers", max_pages=1):
    print(item)
```

## CSV responses

```python
csv_bytes = api.csv("exportUsers")

with open("users.csv", "wb") as file:
    file.write(csv_bytes)
```

## Project Structure

```text
openapiclient/
├─ __init__.py
├─ base.py
├─ client.py
├─ exceptions.py
├─ openapi.py
├─ pagination.py
└─ proxy.py
```

## Future features

- Dynamic pagination config (the current pagination implementation assumes fixed response field names).

## License

MIT
