SchemaSerializable
Anchor::SchemaSerializable
Include this concern in your JSONAPI::Resource
classes to enable type annotations and serialization via an Anchor schema generator.
.anchor_meta_schema
Example
.anchor_links_schema
Example
.attribute
JSONAPI::Resource.attribute
.Adds an optional second argument to annotate it with a type from Anchor::Types
.
Options hash becomes third argument if annotation included. Original JSONAPI::Resource
signature remains the same otherwise.
Example
.relationship
JSONAPI::Resource.relationship
.Adds an optional second argument to annotate it with an
Anchor::Types::Relationship
.
Options hash becomes third argument if annotation included. Original JSONAPI::Resource
signature remains the same otherwise.
Example
.anchor_fetchable_fields
- Type:
Any -> Array<Symbol>
Determines the fields to be serialized for a resource. By default, JSONAPI::Resource.fields
is used.
Useful when you want to generate a context specific schema.
Example
.anchor_schema_name
- Type:
String | (String -> String)
The identifier used when referencing the resource during serialization.
Example
By default, the demodulized name of the class minus "Resource" is used as the schema name for the resource, e.g. SomeModule::UserResource => User
.
Relevant Configs
use_type_as_schema_name
- When
true
, theString#classify
'dtype
thatJSONAPI::Resource
determines from the resource will be used.
- When