Skip to content

test(schemas): check schemas against Draft-07 - #406

Open
LKSNDRTMLKV wants to merge 1 commit into
mainfrom
test/draft07-conformance
Open

LKSNDRTMLKV wants to merge 1 commit into
mainfrom
test/draft07-conformance

Conversation

@LKSNDRTMLKV

Copy link
Copy Markdown
Member

Closes #379.

Every product group schema declares Draft-07, but schema_conformity.rs only showed that each one compiles in the library that enforces it. That is circular: a schema the library tolerates and Draft-07 forbids would have passed. This adds the two independent checks the issue asked for, and makes the register's first conformance claim under the rule from #378.

What runs

crates/dpp-tests/tests/json_schema_draft07.rs, in just check:

Test Holds
every_shipped_schema_declares_draft07_and_is_compiled_as_draft07 every schema declares Draft-07, and the registry's validator_for resolves each to Draft-07
every_shipped_schema_is_valid_against_the_draft07_metaschema each validates against the official meta-schema
the_metaschema_check_rejects_what_it_is_for the check rejects a bad type, required, minimum, minLength, enum, pattern and additionalProperties, at any depth
the_metaschema_ignores_a_misspelt_keyword asserts the meta-schema's blind spot: Draft-07 permits unknown keywords
every_keyword_and_format_a_schema_uses_has_its_suite_file_vendored closes that blind spot: fails on any keyword that is not Draft-07's, and on any used keyword or format whose suite file is not vendored, naming the file
every_vendored_suite_case_passes 22 official suite files, 153 groups and 710 cases, against the pinned jsonschema crate. All pass and none is excluded
the_suite_harness_reports_what_it_is_for the harness reports a wrong verdict and a schema that does not compile
every_ref_in_a_shipped_schema_is_local the workspace builds jsonschema without remote retrieval, so no schema may leave its document
the_vendored_files_are_the_bytes_recorded_here sizes and SHA-256 match NOTICE.md, and an unrecorded file fails

Everything passed on the first run, so no schema changed. I also broke it on purpose and reverted: a flipped suite verdict, a removed suite file, and a misspelt keyword plus an invalid type planted in a shipped schema were each caught, with a message naming the problem.

Vendored files

crates/dpp-tests/fixtures/json-schema/ holds:

  • the Draft-07 meta-schema from json-schema.org;
  • the files of json-schema-org/JSON-Schema-Test-Suite (MIT) at commit 5b0ee1613e45fcc2bddac00e07c19cd49b00d8a8 for the keywords and formats the schemas use, with its LICENSE.

That is 164 KB in all. Source, retrieval date, size and SHA-256 of each file are in NOTICE.md, and .gitattributes pins them -text, as it does for the vendored AAS schemas. Only the files in use are vendored. When a schema needs another, the census above fails and names the file to take. crates/dpp-tests is not published.

The register

The JSON Schema row of docs/architecture/STANDARDS.md now reads Yes, with its class, scope and known deviations, and the statement that it is self-declared. It is the first claim in the register. Not run: the keywords no schema uses (patternProperties, if/then/else and others), and remote $ref retrieval.

Two edits outside the new test

  • standard_citations.rs skips the vendored suite directory. The suite's own text mentions RFC 8141 in its URN cases, which the tripwire counted as this repository citing it, and a register row would claim the code implements URN syntax. The files' bytes are held by their hashes instead. The skip and its reason are in the module docs.
  • sha2 and hex, both already in the workspace, are added as dev-dependencies of dpp-tests for the hash check.

just check is green: 1716 tests, plus the plugin suites.

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.

Check every schema against the Draft-07 metaschema and test suite

1 participant