Skip to content

JSON Resource Specification

Byron Ruth edited this page Aug 8, 2014 · 1 revision

Origins defines a JSON-serializable format for representing resources. It contains four top-level attributes:

  • version - Format version. This should be specified to prevent backwards compatibility issues across versions of the format.
  • resource (required) - An object containing the attributes of the resource itself.
  • components - A map of components where keys are the stable component IDs and the values are objects containing the component attributes.
  • relationships - A map of relationships where keys are the stable relationship IDs and the values are objects containing the relationship attributes.

Core Attributes

Core attributes apply to all objects. These attributes are interpreted by Origins for use in identification and indexing. Object-specific constraints or semantics are discussed in the object's section.

  • id (required) - A natural identifier of the object.
  • uuid - An auto-generated random UUID for the object.
  • label - A human-readable label of the object.
  • description - A verbose description of the object.
  • type - A classification type of the object.

Component Attributes

The id attribute must be unique relative to the resource that manages the component, but not necessarily unique to the graph.

  • resource - An ID of an external resource. If supplied, this denotes the component is externally managed and as a result only included, but not managed by the current resource.
  • parent - ID of the structural parent of the current component.

Relationship Attributes

The id attribute must be unique relative to the resource that manages the relationship, but not necessarily unique to the graph.

  • resource - An ID of an external resource. If supplied, this denotes the relationship is externally managed and as a result only included, but not managed by the current resource.
  • start - ID of the start component
  • end - ID of the end component
  • directed (experimental) - A boolean denoted the relationship is directed. Default is false.
  • dependence (experimental) - A boolean denoting the components have a dependency on each other. That is, if a component changes, an event will be triggered on behalf of the other component. If directed is true, the dependence is one-way (end depends on start), otherwise it is a bi-directional dependence.

JSON Representation

{
    "version": 1.0,
    "resource": {
        "id": "...",
        "label": "..."
    },
    "components": {
        <id>: {
            "label": "...",
            "type": "...",
            "properties": {...}
        },
        ...
    },
    "relationships": {
        <id>: {
            "label": "...",
            "type": "...",
            "start": <component id>,
            "end": <component id>,
            "properties": {...}
        },
        ...
    }
}

Example

{
    "version": 1.0,
    "resource": {
        "id": "https://api.twitter.com/1.1/statuses/user_timeline.json",
        "label": "User Timeline",
        "description": "Returns a collection of the most recent Tweets posted by the user indicated by the screen_name or user_id parameters."
    },
    "components": {
        "service": {
            "label": "User Timeline",
            "description": "Returns a collection of the most recent Tweets posted by the user indicated by the screen_name or user_id parameters.",
            "type": "Service"
        },
        "payload": {
            "label": "Response Payload",
            "description": "An array of Tweets",
            "type": "Tweets"
        },
        "parameters/user_id": {
            "label": "user_id",
            "description": "The ID of the user for whom to return results for.",
            "type": "Parameter",
            "properties": {
                "data_type": "integer"
            }
        },
        ...
    }
}

Note: since the ID is used as the key for the components and relationship maps, the id does not need to be supplied in the attributes.

Clone this wiki locally