Omnist logo Omnist Tutorial Step 5 of 15

OSD — schema syntax

Named records, cardinality, and the three kinds of field a schema can declare.

OSD (Omnist Schema Definition) describes a schema as named records — each a closed set of fields, every field with a declared cardinality (how many times its label may occur) and a type: a scalar, a reference to another record, or the explicit escape hatch any.

record Address {
    "street": string,
    "city": string,
}
record User {
    "name": string,
    "emails" [1,]: string,     # one or more -- cardinality [min,]
    "address": Address,        # a reference to another record
    "note": string?,           # nullable scalar
}
root User

Cardinality shorthand: field with no bracket means exactly one ([1,1]); [0,1] is optional; [0,] is zero-or-more (an array that may be empty); [1,] is one-or-more. ? makes a scalar nullable — a separate question from cardinality entirely (a field can be optional, nullable, both, or neither).

Records are closed by default — a document with a field the record doesn't declare is invalid. The one deliberate opening is any, which accepts anything and stops all further checking beneath it.

Learn more