Metadata-Version: 2.3
Name: restcodegen
Version: 0.1.0
Summary: 
Author: Menshikov Valeriy Sergeevich
Author-email: vmenshikov@ozon.ru
Requires-Python: >=3.11,<4.0
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Dist: click (>=8.1.8,<9.0.0)
Requires-Dist: curlify2 (>=2.0.0,<3.0.0)
Requires-Dist: datamodel-code-generator (>=0.26.5,<0.27.0)
Requires-Dist: httpx (>=0.28.1,<0.29.0)
Requires-Dist: jinja2 (>=3.1.5,<4.0.0)
Requires-Dist: loguru (>=0.7.3,<0.8.0)
Requires-Dist: mypy (>=1.14.1,<2.0.0)
Requires-Dist: pydantic-settings (>=2.7.1,<3.0.0)
Requires-Dist: ruff (>=0.9.2,<0.10.0)
Requires-Dist: structlog (>=25.1.0,<26.0.0)
Description-Content-Type: text/markdown

# RestCodeGen

RestCodeGen is a tool for generating Python clients based on OpenAPI 3 specifications.   
This tool enables testers to quickly create client libraries for interacting with REST APIs implemented with OpenAPI.

## Installation

To install, you need the required dependencies. Make sure you have Python 3.6 or higher installed.

```bash
pip install restcodegen
```

## Usage

Once installed, you can use the restcodegen command to generate a client.

### Command Syntax

```bash
restcodegen generate -u "http://example.com/openapi.json" -s "my-service" -a false
```

### Command Parameters

```
- --url, -u: URL of the OpenAPI specification (required).
- --service-name, -s: Name of the service (required).
- --async-mode, -a: Flag to enable asynchronous client generation (default is false).
```

### Example

To generate a client for an API available at the URL https://petstore3.swagger.io/api/v3/openapi.json, you can use the following command:

```bash
restcodegen generate -u "https://petstore3.swagger.io/api/v3/openapi.json" -s "petstore" -a false
```

### Result

After a successful command execution, a client library will be created with a name corresponding to the provided service name. The generated files will contain classes and methods for interacting with the API described in the provided specification.

Structure:

```
└── clients                      
     └── http     
        ├── schemas               # OpenAPI 3.0.0 schemas for all generated apis                   
        └── service_name          # Service name     
            ├── apis              # APIs                    
            └── models            # Pydantic models   
```

### Generated client usage

```python
from restcodegen.rest_client.client_sync import ApiClient
from restcodegen.rest_client.configuration import Configuration
from clients.http.petstore import PetApi


if __name__ == '__main__':
    configuration = Configuration(host="https://petstore3.swagger.io/api/v3")
    api_client = ApiClient(configuration)
    pet_api = PetApi(api_client)
    response = pet_api.get_pet_pet_id(pet_id=1)
    print(response)
```

## License

This project is licensed under the MIT License. See the LICENSE file for more information.

---

I hope that RestCodeGen will simplify your work with REST APIs. If you have any questions or suggestions, please create an issue in the repository.

