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 locust-openapi-generator
locust-openapi-generator 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.2.tar.gz (4.5 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.2-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: locust_openapi_generator-0.1.2.tar.gz
  • Upload date:
  • Size: 4.5 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.2.tar.gz
Algorithm Hash digest
SHA256 6498944bb7430834705595b087f7ae30a824d68ab1a1f623675ffd3e771387b6
MD5 f4ae463ddb8647976f085395290ab4d9
BLAKE2b-256 5d1ad00a8583956440ffa82700ed05f3b1b9aa62617bab1aff9ff90b22b4eb4e

See more details on using hashes here.

Provenance

The following attestation bundles were made for locust_openapi_generator-0.1.2.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.2-py3-none-any.whl.

File metadata

File hashes

Hashes for locust_openapi_generator-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 95a338e90bff73a42750e5d25063135368fb195a13401db1b4f3e8e182beed02
MD5 fdff2bd0a2d30e467ad150e6a86f80ee
BLAKE2b-256 89ac552a75ace24ba5c73d1dc4b745634f362cc01f1d04e89665ec0396352da7

See more details on using hashes here.

Provenance

The following attestation bundles were made for locust_openapi_generator-0.1.2-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