Skip to main content

Serve an OpenAPI spec as a mock with respx.

Project description

Build Status PyPI

Serve an OpenAPI spec as a mock with respx.

Installation

uv pip install openapi-mock

Or with pip:

pip install openapi-mock

Usage

from http import HTTPStatus

import httpx
import respx

from openapi_mock import add_openapi_to_respx

spec = {
    "openapi": "3.0.0",
    "paths": {"/pets": {"get": {"responses": {"200": {"description": "OK"}}}}},
}
with respx.mock(base_url="https://api.example.com", assert_all_called=False) as m:
    add_openapi_to_respx(mock_obj=m, spec=spec, base_url="https://api.example.com")
    response = httpx.get("https://api.example.com/pets")
assert response.status_code == HTTPStatus.OK

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

openapi_mock-2026.3.1.tar.gz (111.7 kB view details)

Uploaded Source

Built Distribution

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

openapi_mock-2026.3.1-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file openapi_mock-2026.3.1.tar.gz.

File metadata

  • Download URL: openapi_mock-2026.3.1.tar.gz
  • Upload date:
  • Size: 111.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for openapi_mock-2026.3.1.tar.gz
Algorithm Hash digest
SHA256 a097391c4d57c4da68cb24fb88b20c0026b9e4ddf05fd97020cb23c897dadb78
MD5 95aa2085377d336e59bfff14e0034e12
BLAKE2b-256 7f7ec5b3c8b9f53b68d82bb48c8cecc585e263be1edaa90ff918c283bf3875a4

See more details on using hashes here.

Provenance

The following attestation bundles were made for openapi_mock-2026.3.1.tar.gz:

Publisher: release.yml on adamtheturtle/openapi-mock

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

File details

Details for the file openapi_mock-2026.3.1-py3-none-any.whl.

File metadata

File hashes

Hashes for openapi_mock-2026.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 23cc12605df81e8b9f3a4a6c4208354d1c1a3b004bc5f088f81fa5ec2057868d
MD5 ddeff1aa3e07f0ce47e46348ca88c2f8
BLAKE2b-256 104fcba70e91b229655439a13cff88e5c28c3d96adc355694fbe8025ac544589

See more details on using hashes here.

Provenance

The following attestation bundles were made for openapi_mock-2026.3.1-py3-none-any.whl:

Publisher: release.yml on adamtheturtle/openapi-mock

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