Metadata-Version: 2.4
Name: locust-openapi-generator
Version: 0.1.0
Summary: A clean utility tool to convert OpenAPI specs directly into locustfiles
Author: Oleksii Demennikov
License-File: LICENSE
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.8
Requires-Dist: jinja2>=3.0
Requires-Dist: openapi-spec-validator>=0.5
Requires-Dist: prance>=0.22
Description-Content-Type: text/markdown

# OpenAPI to Locust Generator

A lightweight command-line utility that parses an OpenAPI specification (Swagger/OAS 3.0) and generates a clean, PEP8-compliant `locustfile.py` with auto-mocked query parameters and JSON request bodies.

## Features

- **Robust OpenAPI Parsing:** Uses `prance` to resolve internal `$ref` links and complex structural schemas.
- **Payload & Parameter Mocking:** Automatically creates mock data structures based on property types (`uuid`, `date-time`, arrays, etc.) for `GET`, `POST`, `PUT`, and `PATCH` requests.
- **Syntax Isolation:** Automatically sanitizes operation descriptions, handles punctuation gracefully, and eliminates template gaps.

---

## Install 
```bash 
pip install openapi-to-locust-gen
openapi-to-locust openapi.json 
```

## Local Installation & Setup

If you are developing locally on your laptop, follow these steps to isolate your dependencies and get started.

### 1. Clone the Repository
```bash
git clone [https://github.com/your-username/your-repo-name.git](https://github.com/your-username/your-repo-name.git)
cd your-repo-name
```
### 2. Create and Activate a Virtual Environment
Isolate your workspace packages using Python's built-in `venv` module.
On macOS/Linux:
```bash 
python3 -m venv .venv
source .venv/bin/activate
```
On Windows (Command Prompt):
```dos 
python -m venv .venv
.venv\Scripts\Activate
```
On Windows (PowerShell):
```powershell 
python -m venv .venv
.\.venv\Scripts\Activate.ps1 
```
### 3. Install dependencies
Install the required tools directly via the `requirements.txt` manifest:
```bash 
pip install --upgrade pip
pip install -r requirements.txt
```

## Usage 
You can run the script directly from your terminal by passing your OpenAPI JSON or YAML spec file.

## Basic Generation
Generates a standard locustfile.py in your current directory:
```bash 
python src/openapi_to_locust/generator.py path/to/openapi.json 
```

## Custom Output Name 
Change the target filename using the -o or --output flag: 
```bash 
python src/openapi_to_locust/generator.py path/to/openapi.yaml -o dynamic_load_test.py 
```

---

Powered by

<a href='https://decodeapps.pp.ua/'><img height="20" src="https://decodeapps.pp.ua/_next/static/media/logo-light.3763f5cc.svg" /></a>

