Attribute Reference
Supported built-in attributes, targets, and arguments.
Attributes precede the element they annotate. Use #[...] for definitions, fields, and cases, or #![...] for schema metadata. The attribute guide explains syntax.
JSON
| Target | Arguments | Meaning |
|---|---|---|
| Opaque type | type = "...", schema = "..." | JSON shape and optional JSON Schema reference |
| Record | rename_all = "..." | Default field naming |
| Field | name = "...", rename = "...", inline | Explicit name, naming convention, or flattening metadata |
| Variant | rename_all = "...", tagged = ..., tag = "...", content = "..." | Case naming and tagging |
| Variant case | name = "...", rename = "...", content = "..." | Case name and content field override |
JSON shape names are number, boolean, string, null, object, array, and any. Combine them with |, as in "string|null".
Naming conventions are none, lowercase, UPPERCASE, camelCase, PascalCase, snake_case, SCREAMING_SNAKE_CASE, kebab-case, and SCREAMING-KEBAB-CASE.
Tagging values are unquoted paths: internally, adjacently, externally, and implicitly. Defaults are internal tagging, tag for the tag key, content for the payload key, camelCase record fields, and unchanged case names.
The parser accepts inline metadata, but flattening support is not uniform across current backends. Prefer an explicit record structure when sharing models between languages. See JSON mapping for supported tagging examples.
Rust
| Target | Arguments |
|---|---|
| Definition | type = "...", derive(...), attr(...) |
| Field | name = "...", pub, pub(crate), pub(super), private, box, arc, rc, wrap = "..." |
Fields are public by default. pub and private cannot both apply to a field. Indirection attributes wrap the native field type without changing JSON shape. derive and attr arguments accumulate.
#[rust(derive(Clone, Debug), attr(non_exhaustive))]
record Profile {
#[rust(private)]
display_name: string,
}
A bare #[default] on a record field tells the Rust builder plugin to initialize it with Default::default() instead of adding it to the constructor arguments.
Python
#[py(typ = "module.Type")] maps an opaque definition to a native Python type:
#[json(type = "string")]
#[py(typ = "uuid.UUID")]
opaque UserId
The argument is named typ, while the Rust attribute uses type.
Validation
Targets are fields, records, wrappers, and opaque types. Each attribute contains one expression and optional message and code strings:
#[validate({ 1 <= _.size <= 64 }, message = "Use 1 to 64 characters.", code = "name:size")]
Repeat attributes for multiple rules. See validation for expression syntax, generator activation, and runtime limitations.
API Lifecycle
These attributes target definitions, fields, cases, and schemas:
| Attribute | Arguments |
|---|---|
deprecated | Optional since, remove_in, and note strings; may be bare |
unstable | Optional feature, note, and issue strings; may be bare |
since | Required version string |
See API lifecycle for lint behavior and migration examples.
Requests
request applies to a request definition and requires:
name = "...": wire request identifier.response = Type: resolved response type reference.
#[request(name = "tasks.CreateTask", response = CreateTaskOutput)]
record CreateTask {
title: string,
}
Define or import CreateTaskOutput in the same bundle. Request metadata explains how tools can consume this relationship.
Attribute Plugin Schemas
attrs and attr describe custom typed attribute plugins:
#[attrs(plugin = "ui", target = record, repeated)]
record UiRule {
#[attr(name = "label")]
display_label: string,
}
They are compiler extension metadata. See extending Sidex for discovery and generator integration.