Union schema
The variant for a union, which accepts a value that matches any one of the schemas listed under anyOf.

Extends · closed

A variant of the — one of the shapes a schema is allowed to take.
anyOf
The alternative schemas; a value must match at least one. When every arm is a literal, editors show a dropdown.
of
description
What the union is for, when it is written inline; a published schema is described by its page.
optional
params
Type parameters that make this schema generic, each with its default schema.
⟨ * : ⟩optional
name
Legacy: a name some published schemas still carry. New schemas are named by their page.
optional

anyOf: the union keyword. It holds a list of schemas, and a value is valid if it matches any of them. It is the one composite construct in the schema language. A union whose arms are all literals is a fixed set of choices ({anyOf: ["draft", "published"]}), which the editors show as a dropdown.

This document describes the schema/anyof type, one variant of the meta-schema. Its formal schema is attached as the schemaDefinition in this document's metadata, so the app can show it and create values of this type. Typed documents explains how that works.

A union lists alternative schemas under anyOf. A value is valid if it matches any of them. When every arm is a literal, the union is a fixed set of choices, such as {"anyOf": ["draft", "published", "archived"]}. The editors offer that union as a dropdown.

An empty union, {"anyOf": []}, accepts no values. The library names this schema none. It differs from the literal schema null, which accepts the single value null.

See also

Do you like what you are reading? Subscribe to receive updates.

Unsubscribe anytime