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

Uploaded Python 3

File details

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

File metadata

  • Download URL: pytest_httpchain_jsonref-0.8.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.8.0.tar.gz
Algorithm Hash digest
SHA256 557d85f4265282d0a0b728bb9037f9f0cde168fa575f2907c061c904b79d2db3
MD5 aea7738c6fcd453d47e85774daabedbc
BLAKE2b-256 296a65d8b60bb53475c57ae93dc6e823a72d3d61dd305684996fb75235cc9a93

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pytest_httpchain_jsonref-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0faa6c46f3db847670267255402aa4b1d6186b0995319a59a44b0c7ca11187e9
MD5 657b854abba657b58d1b6e443abf4165
BLAKE2b-256 642b743a3bc6c8b142723c1118ea2fdaa346fafd081b3cf0e9b55be6931f3abb

See more details on using hashes here.

Provenance

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