Repository navigation
Ships the datamodel document's JSON Schema - #36
Merged
Merged
Conversation
Adds priv/schemas/datamodel-document.schema.json, a hand-written draft-07 schema of the version-1 document per ADR-0002, to the Hex package, and StatifierDatamodel.Schema with path/0 and json/0 (the text embedded at compile time). Nothing in lib/ calls it: index/1 stays the admission step and answers as before. Tests validate with ex_json_schema, test-only: two fixture documents (ADR-0001's worked shape, and a copy of the reference host's card-processing document with the scope descriptions it omits), the near-misses the schema rejects, each still indexing as before where it is a document at all, the nine closed spellings pinned to the index, and the built file list. Refs: sd-630
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ships the datamodel document's JSON Schema, as ADR-0002 (merged at proposed) decides it. Refs sd-630.
What changes
priv/schemas/datamodel-document.schema.json: a hand-written draft-07 schema of the version-1 document.versionisconst: 1;scopesis a tuple of exactly three scope objects fixed byconsttoglobal,local,event; an entry requiresname,path,type,labelas strings, withfields(recursive),item_type,example(any value),note,one_ofand a booleansensitive?; a declaration requiresname,kind(recordorshape),labelandfields; a field requiresnameandtype, with a booleanrequired?. The nine closed spellings are listed underdefinitions.closed_type;typeanditem_typeare plain strings (decision 6). No object setsadditionalProperties: false(decision 7).$idis keyed on document version 1 (decision 8).StatifierDatamodel.Schema:path/0(the file in the installed application'spriv) andjson/0(the text, embedded at compile time with@external_resource; not a decoded map). Nothing inlib/calls either (decision 4).mix.exs:priv/schemasjoins the Hexfiles:list (decision 1);{:ex_json_schema, "~> 0.11", only: :test, runtime: false}(decision 10: test-only;mix hex.buildlists no requirements).mix.lockgainsex_json_schemaanddecimal.changelog.d/sd-630.md(Added).Tests (
test/statifier_datamodel/schema_test.exs)test/fixtures/documents/validates and indexes to a non-nil index. The two fixtures: ADR-0001's## Worked shapeJSON extracted verbatim, and a copy of the reference host's card-processing document (riddler/statifier_examplespriv/fixtures/card-processing.datamodel.jsonat fed826ca9d0fed20e1c6152a528a0f2885d3d2fd), with one edit named below.path; a stringsensitive?; a declarationkindneitherrecordnorshape; a declaration missingfields; a stringrequired?; version 2. Each is rejected at the error path it breaks.scopes(all but "scopes missing") still indexes, and what it indexes to is pinned (the declared paths, the entries, the sensitive set, the declarations, the version, as the case needs). "scopes missing" is pinned tonil.definitions.closed_typeindexes to a non-nil type throughIndex.type/2(one entry per spelling, queried by its path), the listed set equals the nine, andfloatindexes tonil. An entry whosetypenames a declaration validates and indexes to{:declared, "cards.credit_txn"}.priv/schemas/datamodel-document.schema.json(thefiles:entries expanded as Hex expands them); a realmix hex.build --unpackof this branch was also read and carries the file.Provenance
descriptionon all three scopes, which ADR-0001 decision 3 has a scope carry and ADR-0002 decision 5 requires, so the verbatim copy does not validate. The fixture adds adescriptionto each scope and changes nothing else; a test deletes the three again and pins that the result fails at exactly#/scopes/0,#/scopes/1,#/scopes/2and indexes identically to the fixture. The source document is not edited here.labelanddescription, a declaration'snameandlabel), the schema requires the key and adds no type.mix.exsgroups_for_modules:Schemajoins the "Document and index" group so the new module is not left ungrouped in the docs sidebar (a threading edit).runtime: falseon the test-only validator, beside the record'sonly: :test.Pre-request review
Read the diff against ADR-0002 decisions 1-10, its typespecs and its worked example, and against the bead's acceptance. Checked: every key and requirement decision 5 lists is in the file and nothing is required that it does not list; the tuple,
minItems/maxItemsand the threeconstpositions match the record's outline;closed_typeholds exactly the nine spellings inindex.ex's@types; noadditionalPropertiesanywhere;json/0returns the text;grep -rni schema liboutsideschema.exfinds nothing, so no function's answer changes; the worked-example rows of ADR-0002 (event scope dropped, a stringsensitive?,kindshap, version 2, a declared-nametype) each hold as the record states them. The moduledoc claims (advisory, stricter thanindex/1,$idkeyed on document version) each match a decision above.Gate
Full
mix qualityon the committed tree, quoted whole:The commit is a bare
git commitof a staged tree byte-identical to the tree this run passed on.