Skip to content

Examples

These pages show how to write, check, use and build MIDAS Catalog records. Several of them use an example record: a minimal, valid Dataset modeled on catalog record 350 (CDC's 2022–2023 mpox case counts).

  • Write a record in YAML: the fields a record has, the rules its identifiers follow, and how to check a record you write.
  • Check a record: check the example record as a Dataset with LinkML's validator, check it against the model's JSON Schema, and see what an error looks like.
  • Other ways to check a record: check it with Python's jsonschema library, and see which files LinkML's validator can't check.
  • Use catalog records in a script: download the whole catalog and list the records about mpox, with nothing but Python's standard library.
  • Get a catalog record as YAML: convert a record the catalog publishes into plain YAML.
  • Build a record in code: generate Python classes from the model, build the example record as objects, and validate the JSON they write.

Download the files

The example files are the record as YAML, JSON and JSON-LD, and three deliberately invalid copies. LinkML's validator also needs the model's YAML file. Make a folder, and download the files into it. The pages that write and check a record run their commands in that folder:

mkdir midas-example && cd midas-example
curl -L -o midas-catalog.yaml https://w3id.org/midas-catalog/linkml/generated/midas-catalog.yaml
curl -sSfL --create-dirs \
  -O https://midas-network.github.io/midas-catalog-linkml/examples/dataset-350.yaml \
  -O https://midas-network.github.io/midas-catalog-linkml/examples/dataset-350.json \
  -O https://midas-network.github.io/midas-catalog-linkml/examples/dataset-350.jsonld \
  -o invalid/dataset-350-bad-subject.yaml https://midas-network.github.io/midas-catalog-linkml/examples/invalid/dataset-350-bad-subject.yaml \
  -o invalid/dataset-350-no-agenttype.yaml https://midas-network.github.io/midas-catalog-linkml/examples/invalid/dataset-350-no-agenttype.yaml \
  -o invalid/dataset-350-curie-type.jsonld https://midas-network.github.io/midas-catalog-linkml/examples/invalid/dataset-350-curie-type.jsonld