SchemaDefault

Field-level UDA declaring a default value (the JSON Schema default keyword) for a struct field. Named @schemaDefault to avoid clashing with D's default keyword. When jsonSchemaOf!T reflects over a struct, a field annotated with @schemaDefault(v) emits "default": v on its property schema, serializing the value (an enum value is emitted as its wire string, a bool as a JSON boolean, etc.).

@safe
struct SchemaDefault (
T
) {}

Members

Variables

value
T value;

the default value emitted (serialized) as JSON Schema default

Examples

struct Form
{
    @schemaDefault(false) bool verbose;
    @schemaDefault(10) int limit;
}

The payload struct carrying a @schemaDefault value. Construct it via the schemaDefault(value) factory below rather than naming it directly; the reflection layer detects it with isInstanceOf!(SchemaDefault, UDA).