macro_rules! resource_schema {
($name:literal $({ $($member:tt)* })?) => { ... };
}Available on crate feature
domain only.Expand description
Build an ash_domain::schema::ResourceSchema literal.
ResourceSchema has ten fields, most of which serialization ignores.
Writing one by hand is noise; this fills in the defaults.
For tests, examples and fixtures only. A real service takes its schema
from Domain::schema() — a resource is declared once, with
#[derive(Resource)], and never restated.
ⓘ
use ash_jsonapi::resource_schema;
let schema = resource_schema! {
"todo" {
message: String,
owner -> "user",
tags -> ["tag"],
}
};
assert_eq!(schema.name, "todo");
assert_eq!(schema.attributes.len(), 1);
assert_eq!(schema.relationships.len(), 2);name: Type declares an attribute — String, Integer, Number,
Boolean or Bytes. -> "user" declares a to-one relationship;
-> ["tag"] a to-many, the brackets reading as “many of these”.