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.1.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.1-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: locust_openapi_generator-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 765b271365d2308760ec53225ba6471b7a9567c72734fd239009f45f4bf871f9
MD5 dd30349b88d4741c45677e215781bb4e
BLAKE2b-256 9bfeab06a54df2e7f52fb9538d483d1007a97050174c8ffebb185964f45032fd

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for locust_openapi_generator-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7688442fefe02685ebed3be7cfc67e8baf7a77b5ba0d12deaab80b30bfdbaab6
MD5 5849a794c819a6726be230339c7031be
BLAKE2b-256 e738a98f05afbe3249f7d0edc1af5d6ba96bfae982b55a180025a9054d1523b0

See more details on using hashes here.

Provenance

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