View source: R/schema_contract.R
| assert_config_contract | R Documentation |
Checks one generated JSON Schema against the rules a config document must obey, and throws if any is broken. Shared by every package that publishes to schema.rtemis.org – rtemis and rtemis.draw – so one registry cannot hold documents held to two standards.
assert_config_contract(schema, id = schema[["$id"]], structural = character())
schema |
Named list: The generated schema, as |
id |
Character: The schema's |
structural |
Character: Keys this schema may require because they carry the document's shape rather than a value – a family dispatcher's discriminator. Empty for a leaf or a flat config. |
Five rules, each recorded where it is raised:
No top-level required beyond the key carrying the document's shape:
a family dispatcher's discriminator, which selects the variant whose
settings are its siblings. A config is otherwise a partial expression of
intent.
No default: defaults are versioned separately, in defaults/v1.
No conditional demand for a key (then/else with required, or
dependentRequired): an implementation could satisfy it by filling a
value, which makes it a resolution rule and belongs to the record form.
No R construct named in a description: the corpus is language-independent and is read by R, by the Rust CLI, by the browser, and by a model that writes no code at all.
No R spelling of a value in a description: NULL, TRUE, FALSE, NA
and the @property accessor are R, not JSON.
The first three are about what a config may demand, and record schemas are
not subject to them: a record states what a run used, so everything in it is
required. The last two are about prose, which every published document has;
assert_description_language() applies just those, for a record or a result
class that does not come through here.
The schema, invisibly, so it can wrap a write call. Throws with
class simpleError listing every rule broken, so one run reports all of
them rather than the first.
EDG
assert_config_contract(
list(type = "object", properties = list(k = list(type = "integer"))),
"https://schema.rtemis.org/example/v1/schema.json"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.