Skip to main content

Version Compatibility Notice

  • For versions of this package below 1.0.0, only version 1 of the d42 package is compatible.
  • For versions of this package 1.0.0 and later, only version 2 of the d42 package is compatible.

Usage

  1. Decorate your mocked function with @validate_spec(), providing a link to a YAML or JSON OpenAPI spec.
import jj
from jj.mock import mocked
from jj_spec_validator import validate_spec


@validate_spec(spec_link="http://example.com/api/users/spec.yml")
async def your_mocked_function():
    matcher = jj.match("GET", "/users")
    response = jj.Response(status=200, json=[])
    
    mock = await mocked(matcher, response)
  1. is_strict key allows choosing between strict and non-strict comparison. Non-strict comparison allows you to mock only some fields from the spec. False (= non-strict) by default.

  2. Use the prefix key to specify a prefix that should be removed from the paths in the mock function before matching them against the OpenAPI spec.

from jj_spec_validator import validate_spec


@validate_spec(spec_link="http://example.com/api/users/spec.yml", prefix='/__mocked_api__')  # Goes to validate `/users` instead of `/__mocked_api__/users`
async def your_mocked_function():
    matcher = jj.match("GET", "/__mocked_api__/users")
    ...
  1. is_raise_error key allows raising an error when a mismatch occurs. False by default.

  2. force_strict key allows enforcing strict validation against the downloaded spec. This is useful when the spec is occasionally have all dicts relaxed. False by default.

Metadata

Release files for jj-spec-validator 1.0.0

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

Source distribution (sdist)

Source distribution for jj-spec-validator 1.0.0
File Size Uploaded
jj_spec_validator-1.0.0.tar.gz 8.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for jj-spec-validator 1.0.0
File Interpreter ABI Platform
jj_spec_validator-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 18.3 kB

Release files / jj_spec_validator-1.0.0.tar.gz

Download URL jj_spec_validator-1.0.0.tar.gz
Size 8.3 kB
Tags Source
SHA-256 checksum
How to use checksums
17edc5bc114a73350123fb942d503264e10f5c5036681e0d6ec93c0939b46f99
BLAKE2b-256 checksum
How to use checksums
f40e16ae06894ffaa5ccb6935672715557e33ae74baabd16168771a569529781
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.10.15

Release files / jj_spec_validator-1.0.0-py3-none-any.whl

Download URL jj_spec_validator-1.0.0-py3-none-any.whl
Size 10.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dc838784f4be5dada0528397a4824d982d368c268f695b830ea87bd1b8f6b554
BLAKE2b-256 checksum
How to use checksums
f0fc382ca6438f016ea81b690d80703963d63cbd89521030023c6acb30f02109
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.10.15

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

0.1.20

2 release files

0.1.18

2 release files

0.1.17

2 release files

0.1.16

2 release files

0.1.15

2 release files

0.1.13

2 release files

0.1.12

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

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