Skip to main content

JSON reference ($ref) support for pytest-httpchain

Project description

pytest-httpchain-jsonref

JSON reference ($ref) resolution with deep merging, used by pytest-httpchain.

This package loads a JSON document and resolves reference directives into a single in-memory structure. It supports external file references, JSON-pointer references within a document, and combined file.json#/pointer references. Sibling properties next to a directive are merged additively with the referenced content (keys added, lists concatenated, dicts merged recursively; a conflicting scalar raises rather than silently overriding). It also enforces a few safety constraints — a parent-traversal depth limit, an optional root directory that references may not escape, and circular-reference detection.

Role in the workspace

pytest-httpchain lets an HTTP test scenario be split across reusable JSON fragments. At collection time the plugin calls this package to inline every $ref / $include / $merge directive before the resulting document is validated against the models. It is published separately so the resolution logic can be reused and tested on its own; it is not intended to be used directly outside the plugin.

Usage

from pytest_httpchain_jsonref import load_json, ReferenceResolverError

try:
    data = load_json("scenario.json", max_parent_traversal_depth=3, root_path="tests")
except ReferenceResolverError as e:
    print(f"could not resolve references: {e}")

Three directives are accepted and behave identically — $include and $merge are preferred (they avoid clashing with editor JSON Schema validation), while $ref is the legacy spelling:

{
    "$include": "base.json#/definitions/login",
    "extra": "merged with the referenced content"
}

Links

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

pytest_httpchain_jsonref-0.8.1.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

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

pytest_httpchain_jsonref-0.8.1-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file pytest_httpchain_jsonref-0.8.1.tar.gz.

File metadata

  • Download URL: pytest_httpchain_jsonref-0.8.1.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pytest_httpchain_jsonref-0.8.1.tar.gz
Algorithm Hash digest
SHA256 4fa38b116cae336191fe4695f94a36fb9a3ce3fd4b9130ac61949ddfb33b640f
MD5 ad733b6ce8a506c5498685de15f008ca
BLAKE2b-256 7f51a278b6e36f3586b1600965242685842913ba47fd5fd70c12e9cd1ceb26f2

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_httpchain_jsonref-0.8.1.tar.gz:

Publisher: publish.yml on aeresov/pytest-httpchain

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

File details

Details for the file pytest_httpchain_jsonref-0.8.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_httpchain_jsonref-0.8.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9ee33527026e31cb39fd76ba64c4d69725f4442c233350e49b06bd4985502ca4
MD5 4af99c702dfc8e6568774e8df5586825
BLAKE2b-256 908d085d44dcaf0e8e40d3384458ad5f795c11ddb5c22462d6f373068ea6c174

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_httpchain_jsonref-0.8.1-py3-none-any.whl:

Publisher: publish.yml on aeresov/pytest-httpchain

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