Skip to contents

The family's entry point: a document is a chart if it matches exactly one of the leaf schemas, selected by its type.

Usage

chart_dispatcher_schema(classes, id, leaf_ids, title, description)

Arguments

classes

List: ChartConfig subclasses.

id

Character: The dispatcher's $id URL.

leaf_ids

Character: $id of each leaf schema, in the same order as classes.

title

Character: Human-readable schema title.

description

Character: What the family is.

Value

Named list: The JSON Schema, ready for jsonlite::toJSON().

Author

EDG

Examples

schema <- chart_dispatcher_schema(
  classes = list(ScatterConfig, BarConfig),
  id = "https://schemas.rtemis.org/draw/chart.schema.json",
  leaf_ids = c(
    "https://schemas.rtemis.org/draw/scatter.schema.json",
    "https://schemas.rtemis.org/draw/bar.schema.json"
  ),
  title = "Chart",
  description = "Any rtemis.draw chart."
)
schema[["properties"]][["type"]][["enum"]]
#> [1] "scatter" "bar"