Expand description
#[derive(Shape)] for the trilean-json-shape crate.
The derive reads the serde attributes a type already carries, so one declaration serves serde and the shape:
tag, untagged, rename, rename_all, deny_unknown_fields, default and flatten, plus
skip_serializing_if, which only affects how a value is written and so is accepted and ignored. The shape adds
#[shape(...)] for what serde cannot say.
On a container: strict (the same as deny_unknown_fields), name = "..." (the definition name, which is the
type’s identifier otherwise), together(a, b) (each named field requires the others) and min_properties = n.
On a field, a tuple variant’s field, and a variant of an untagged enum: min = n, max = n, min_length = n,
min_items = n, max_items = n, unique_items, min_properties = n, pattern = "...",
property_names = "..." (a pattern the keys of a map match) and constant = true or constant = "text". Doc
comments become descriptions.
Supported types: a struct with named fields (an object), an enum of unit variants (a string enum), an enum with
#[serde(tag = "...")] whose variants are unit, struct or newtype variants over a struct (an internally tagged
union), and an enum with #[serde(untagged)] whose variants are struct or newtype variants, and at most one unit
variant, which is null (a union that matches exactly one). Anything else, any attribute that is not read at
the position it is written, and any generic parameter is a compile error that names it. A constraint on a type
it does not apply to, a flattened or tagged newtype field that is not a struct, a pattern outside the supported
subset and a property key used twice are compile errors too.