Skip to main content

A clean utility tool to convert OpenAPI specs directly into locustfiles

Project description

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

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

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:

python3 -m venv .venv
source .venv/bin/activate

On Windows (Command Prompt):

python -m venv .venv
.venv\Scripts\Activate

On Windows (PowerShell):

python -m venv .venv
.\.venv\Scripts\Activate.ps1 

3. Install dependencies

Install the required tools directly via the requirements.txt manifest:

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:

python src/openapi_to_locust/generator.py path/to/openapi.json 

Custom Output Name

Change the target filename using the -o or --output flag:

python src/openapi_to_locust/generator.py path/to/openapi.yaml -o dynamic_load_test.py 

Powered by

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

locust_openapi_generator-0.1.0.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

locust_openapi_generator-0.1.0-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file locust_openapi_generator-0.1.0.tar.gz.

File metadata

  • Download URL: locust_openapi_generator-0.1.0.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for locust_openapi_generator-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7f8c31202441671afb8bf2724d2328c36c6bf711f4127383718ee5b73976ff29
MD5 0174e4e46c7cc69954e4dd7d592b3d43
BLAKE2b-256 ed2943a7fce6c623721b1c5966a89969c0184aeb33d72aa2f96df7e4fceb12cc

See more details on using hashes here.

Provenance

The following attestation bundles were made for locust_openapi_generator-0.1.0.tar.gz:

Publisher: publish.yml on FallenAngel97/locust-openapi-generator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file locust_openapi_generator-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for locust_openapi_generator-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 046fd2222361113c641ae1a3e295c64c16f779cf52ab3638b10008a5786e5be6
MD5 ce377c72ad6ae55e4ef331987a456ebb
BLAKE2b-256 a1531300e9cec64cf820d8b0190f447bc005c32b0f9c69a6d7927c9103c206dd

See more details on using hashes here.

Provenance

The following attestation bundles were made for locust_openapi_generator-0.1.0-py3-none-any.whl:

Publisher: publish.yml on FallenAngel97/locust-openapi-generator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page