jj mocks validator for openapi specs
Project description
Usage
- 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)
-
is_strict
key will allow choosing between strict and non-strict comparison. False by default. -
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")
...
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for jj_spec_validator-0.1.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0128c68c6b26c56a12cfc41dbba080a7b18c5118c7d6e7e8cc61a9c929f2c615 |
|
MD5 | aa19daaa6f1bbaa08c959258a298bd4a |
|
BLAKE2b-256 | e5a3a9059ae43f4fd365f0533cf59e8f0473c21e8c3ea7a65ad6b93a779bba06 |