Skip to content

Ignore $ref siblings in supported JSON Schema drafts - #116

Open
Kaiserunix wants to merge 1 commit into
python-jsonschema:masterfrom
Kaiserunix:codex/fix-draft-ref-siblings
Open

Ignore $ref siblings in supported JSON Schema drafts#116
Kaiserunix wants to merge 1 commit into
python-jsonschema:masterfrom
Kaiserunix:codex/fix-draft-ref-siblings

Conversation

@Kaiserunix

Copy link
Copy Markdown

Fixes #97.

Generating values for a non-recursive schema could fail with an unresolvable JSON pointer when a $ref had a sibling items schema. Resolve the referenced schema without merging sibling keywords, matching the supported Draft 4, 6, and 7 semantics. This also avoids treating conflicting sibling constraints as an unsatisfiable schema.

Regression tests cover both definitions and $defs locations across all three supported drafts, plus conflicting sibling constraints. The existing Draft 7 corpus case now declares its draft explicitly so its validation uses Draft 7 instead of the dependency's default newer draft.

Validation on Windows, CPython 3.12, with the repository's pinned test/check dependencies:

  • Nine new regression cases fail on the unchanged implementation and pass with the fix.
  • The original issue schema now generates 20 valid examples without changing the reproduction script.
  • pytest -n 4 --durations=10 -k 'not test_can_generate_for_real_large_schema': 704 passed, 24 skipped, 52 xfailed, 2 xpassed; 100% coverage. These skips and expected-failure markers are existing suite policy, not added by this change.
  • Shed for the changed Python files, Ruff, Black, JSON formatting, and git diff --check passed.
  • Mypy reports ten errors in the unchanged _from_schema.py; the same command and environment against an independent checkout of the base commit produce the identical ten errors.

The separately scheduled slow corpus job and other OS/Python combinations were not run locally. This patch was prepared with AI assistance and independently reviewed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error resolving sub-schema property with type object or array

1 participant