Skip to main content

OAPI2MOCKSERVER

What does it do

It creates expectations for mockserver based on an OpenAPI2 yaml.

If no scenarios are provided, it creates expectations for all endpoints with the first status-code defined. If example values are given in contract, these values will be used for response body.

If scenarios are provided, they must match the defined endpoints in the OpenAPI2 file.

Usage

start a mockserver: docker run -it --rm -P jamesdbloom/mockserver

Create expectations: oapi2mockserver mock localhost:<port_of_mockserver_docker_container> <path_to_open_api_2_contract_yaml>

Scenario Parameter

-s json of scenarios to push to the mockserver

Example: oapi2mockserver mock localhost:32768 foo.yaml -s '{"scenarios":[["\/v1\/foo\/{id}","get","200", "{\"foo\":\"bar\"}", "application/json"]]}'

This pushes one scenario to mockserver with path /v1/foo/{id}, operation get, expected status-code 200, expected response-body {"foo":"bar"} and expected response Content-Type header application/json

Response-Body and Content-Type are optional and will be generated out of the contract if not given. If the Response-Body is a json, it will be validated against the schema defined in the contract before the scenario will be send to mock-server. Also the Content-Type header needs to be defined in produces part of contract before the scenario will be send to mock-server.

Development

run current development state:

  • cd into package root directory
  • install dependencies with pip3 install -r requirements.txt (just before first run or after adding new dependencies)
  • run python3 run.py mock <url_to_mockserver> <path_to_open_api_2_contract_yaml>

Tests

cd into package root directory and run python3 -m unittest discover -s tests -v

Build

cd into package root directory and run pip3 install ./

Upload to pypi.org

WARNING: This will overwrite the current version on pypi.org!

raise version in setup.py, then run ./upload

Metadata

Release files for oapi2mockserver 0.0.14

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for oapi2mockserver 0.0.14
File Size Uploaded Provenance
oapi2mockserver-0.0.14.tar.gz 11.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for oapi2mockserver 0.0.14
File Interpreter ABI Platform
oapi2mockserver-0.0.14-py3-none-any.whl Python 3 none any Details

Total release size: 21.5 kB

Release files / oapi2mockserver-0.0.14.tar.gz

Download URL oapi2mockserver-0.0.14.tar.gz
Size 11.4 kB
Tags Source
SHA-256 checksum
How to use checksums
bcb0664ecfb7412ced686de381c23e826c563c5a3e1afe3ab3de3a5a08cc2f16
BLAKE2b-256 checksum
How to use checksums
02c7c58ebf94f9d6e9e275ef9fda3d55283f37ea9bad8fb5793594fd91bd4ea4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.7.9

Release files / oapi2mockserver-0.0.14-py3-none-any.whl

Download URL oapi2mockserver-0.0.14-py3-none-any.whl
Size 10.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
13470c92ad2b24bfe343f2f64f5465fbe20e8a5ac3181cc6d530db50350269b2
BLAKE2b-256 checksum
How to use checksums
669d50e19f74e9b60b27d61a033355ec6c9bc0d3d4309ad8eabb768a79e98924
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.7.9

Security for oapi2mockserver 0.0.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page