Resource Classes (RCs) are the basic component of the API schema. They describe the behavior of a resource (identified by a URI)
They generally consist of:
data
keywordSee the “Properties” section below for more detail what you can put in a Resource Class.
RCs can have Generics. They can also be extended - see RC Inheritance.
A simple one looks like this:
resource Account {
data Profile
links {
change-password -> ChangePassword,
change-email -> ChangeEmail,
}
PATCH @self% -> @self;
}
This describes a resource representing a user’s account. It has an associated data structure, with links to resources that allow the user to change their email or password, and a PATCH
method that uses the Partial (Lax) Operator to accept incremental changes.
When used for a method output or whatever, raw data types will be formatted as-is.
Resource classes can be used as types, too. When used as an input, this will refer to their base data type; as an output, it will be rendered according to Resource Serialization
Within Links and Methods, there are a few “special” resource classes available, called metaclasses. These all begin with the @
sigil and are described below:
@self
- refers to the Resource Class that contains it. This is useful for the sake of easy maintenance, and may also have some special semantic implications in the future.@empty
is just an empty request/response body. This can be inferred (see “Default Behavior” below), but it’s provided as a special data type to be extra specific if you want to.@media
is a non-data payload, e.g. an image file. It has no semantic implications and exists as a placeholder for anything outside of the Veneto schema that might be sent over the API.