Skip to content

Instantly share code, notes, and snippets.

@kevinswiber
Last active May 11, 2017 00:44
Show Gist options
  • Save kevinswiber/e7e25c101f7044509047c1a3ba11be3e to your computer and use it in GitHub Desktop.
Save kevinswiber/e7e25c101f7044509047c1a3ba11be3e to your computer and use it in GitHub Desktop.
Siren described in MSON for API Blueprint
# Data Structures
## Entity (object)
An Entity is a URI-addressable resource that has properties and actions
associated with it. It may contain sub-entities and navigational links.
### Properties
- class (array[string], optional)
Describes the nature of an entity's content based on the current
representation. Possible values are implementation-dependent and
should be documented.
- title (string, optional)
Descriptive text about the entity.
- properties (object, optional)
A set of key-value pairs that describe the state of an entity.
- entities (array[SubEntity], optional)
A collection of related sub-entities. If a sub-entity contains an href
value, it should be treated as an embedded link. Clients may choose to
optimistically load embedded links. If no href value exists, the
sub-entity is an embedded entity representation that contains all the
characteristics of a typical entity. One difference is that a sub-entity
MUST contain a rel attribute to describe its relationship to the parent
entity.
- actions (array[Action], optional)
A collection of actions; actions show available behaviors an entity exposes.
- links (array[Link], optional)
A collection of items that describe navigational links, distinct from
entity relationships. Link items should contain a `rel` attribute to
describe the relationship and an `href` attribute to point to the target
URI. Entities should include a link `rel` to `self`.
## SubEntity (enum)
- (EmbeddedLinkSubEntity)
- (EmbeddedRepresentationSubEntity)
## EmbeddedLinkSubEntity (object)
### Properties
- class (array[string], optional)
Describes the nature of an entity's content based on the current
representation. Possible values are implementation-dependent and should be
documented.
- rel (array[string], required)
Defines the relationship of the sub-entity to its parent, per Web Linking
(RFC5899).
- href (string, required)
The URI of the linked sub-entity.
- type (string, optional)
Defines media type of the linked sub-entity, per Web Linking (RFC5899).
- title (string, optional)
Descriptive text about the entity.
## EmbeddedRepresentationSubEntity (object)
### Properties
- class (array[string], optional)
Describes the nature of an entity's content based on the current
representation. Possible values are implementation-dependent and
should be documented.
- rel (array[string], required)
Defines the relationship of the sub-entity to its parent, per Web Linking
(RFC5899).
- title (string, optional)
Descriptive text about the entity.
- properties (object, optional)
A set of key-value pairs that describe the state of an entity.
- actions (array[Action], optional)
A collection of actions; actions show available behaviors an entity exposes.
- links (array[Link], optional)
A collection of items that describe navigational links, distinct from
entity relationships. Link items should contain a `rel` attribute to
describe the relationship and an `href` attribute to point to the target
URI. Entities should include a link `rel` to `self`.
## Action (object)
Actions show available behaviors an entity exposes.
### Properties
- class (array[string], optional)
Describes the nature of an action based on the current representation.
Possible values are implementation-dependent and should be documented.
- name (string, required)
A string that identifies the action to be performed. Action names MUST be
unique within the set of actions for an entity. The behaviour of clients
when parsing a Siren document that violates this constraint is undefined.
- method (string, optional)
An enumerated attribute mapping to a protocol method. For HTTP, these
values may be GET, PUT, POST, DELETE, or PATCH. As new methods are
introduced, this list can be extended. If this attribute is omitted, GET
should be assumed.
- Default: GET
- href (string, required)
The URI of the action.
- title (string, optional)
Descriptive text about the action.
- type (string, optional)
The encoding type for the request. When omitted and the fields attribute
exists, the default value is `application/x-www-form-urlencoded`.
- Default: `application/x-www-form-urlencoded`
- fields (array[Field], optional)
A collection of fields.
## Field (object)
Fields represent controls inside of actions.
### Properties
- name (string, required)
A name describing the control. Field names MUST be unique within the set of
fields for an action. The behaviour of clients when parsing a Siren
document that violates this constraint is undefined.
- type (enum[string], optional)
The input type of the field. This is a subset of the input types specified
by HTML5.
- Default: text
- Members
- text
- hidden
- search
- tel
- url
- email
- password
- datetime
- date
- month
- week
- time
- datetime-local
- number
- range
- color
- checkbox
- radio
- file
- title (string, optional)
Textual annotation of a field. Clients may use this as a label.
- value (enum[string, number, array[FieldValueObject]], optional)
A value assigned to the field. May be a scalar value or a list of value objects.
## FieldValueObject (object)
Value objects represent multiple selectable field values. Use in
conjunction with field `"type" = "radio"` and `"type" = "checkbox"` to
express that zero, one or many out of several possible values may be sent
back to the server.
### Properties
- title (string, optional)
Textual description of a field value.
- value (enum[string, number], required)
Possible value for the field.
- selected (boolean, optional)
- Default: false
A value object with a `"selected" = true` attribute indicates that this
value should be considered preselected by the client. When missing, the
default value is `false`.
## Link (object)
Links represent navigational transitions.
### Properties
- class (array[string], optional)
Describes aspects of the link based on the current representation. Possible
values are implementation-dependent and should be documented.
- title (string, optional)
Text describing the nature of a link.
- rel (array[string], required)
Defines the relationship of the link to its entity, per Web Linking
(RFC5988).
- href (string, required)
The URI of the linked resource.
- type (string, optional)
Defines media type of the linked resource, per Web Linking (RFC5988).
@kevinswiber
Copy link
Author

@zdne Thanks! Updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment