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.7.0.tar.gz (7.0 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.7.0-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pytest_httpchain_jsonref-0.7.0.tar.gz
  • Upload date:
  • Size: 7.0 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.7.0.tar.gz
Algorithm Hash digest
SHA256 863e83c35bb615078e36f67d0ba263aa6cc9b7415e9e9a3da448518edc9d26bc
MD5 3988e86504ec051782fd78e5c52bd6bf
BLAKE2b-256 8d5f66bcace672a6463d7d94d2286f20d22777789e6b481abf191d891836b7cb

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_httpchain_jsonref-0.7.0.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.7.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_httpchain_jsonref-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2bdfae9a6bde7456dd59eb3dd25d6d3e6d8639f09490107d6abdaf80987e8279
MD5 1af6459f4184a58563ee45f8bc430efd
BLAKE2b-256 e98919d6419e7fdba0210ecd2b7e551405e5a6b0c9d06add7ab0eb49c592f5ae

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_httpchain_jsonref-0.7.0-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