Chris@18: { Chris@18: "$schema": "http://json-schema.org/draft-06/schema#", Chris@18: "title": "JSON:API Schema", Chris@18: "description": "This is a schema for responses in the JSON:API format. For more, see http://jsonapi.org", Chris@18: "oneOf": [ Chris@18: { Chris@18: "$ref": "#/definitions/success" Chris@18: }, Chris@18: { Chris@18: "$ref": "#/definitions/failure" Chris@18: }, Chris@18: { Chris@18: "$ref": "#/definitions/info" Chris@18: } Chris@18: ], Chris@18: Chris@18: "definitions": { Chris@18: "success": { Chris@18: "type": "object", Chris@18: "required": [ Chris@18: "data" Chris@18: ], Chris@18: "properties": { Chris@18: "data": { Chris@18: "$ref": "#/definitions/data" Chris@18: }, Chris@18: "included": { Chris@18: "description": "To reduce the number of HTTP requests, servers **MAY** allow responses that include related resources along with the requested primary resources. Such responses are called \"compound documents\".", Chris@18: "type": "array", Chris@18: "items": { Chris@18: "$ref": "#/definitions/resource" Chris@18: }, Chris@18: "uniqueItems": true Chris@18: }, Chris@18: "meta": { Chris@18: "$ref": "#/definitions/meta" Chris@18: }, Chris@18: "links": { Chris@18: "description": "Link members related to the primary data.", Chris@18: "allOf": [ Chris@18: { Chris@18: "$ref": "#/definitions/links" Chris@18: }, Chris@18: { Chris@18: "$ref": "#/definitions/pagination" Chris@18: } Chris@18: ] Chris@18: }, Chris@18: "jsonapi": { Chris@18: "$ref": "#/definitions/jsonapi" Chris@18: } Chris@18: }, Chris@18: "additionalProperties": false Chris@18: }, Chris@18: "failure": { Chris@18: "type": "object", Chris@18: "required": [ Chris@18: "errors" Chris@18: ], Chris@18: "properties": { Chris@18: "errors": { Chris@18: "type": "array", Chris@18: "items": { Chris@18: "$ref": "#/definitions/error" Chris@18: }, Chris@18: "uniqueItems": true Chris@18: }, Chris@18: "meta": { Chris@18: "$ref": "#/definitions/meta" Chris@18: }, Chris@18: "jsonapi": { Chris@18: "$ref": "#/definitions/jsonapi" Chris@18: }, Chris@18: "links": { Chris@18: "$ref": "#/definitions/links" Chris@18: } Chris@18: }, Chris@18: "additionalProperties": false Chris@18: }, Chris@18: "info": { Chris@18: "type": "object", Chris@18: "required": [ Chris@18: "meta" Chris@18: ], Chris@18: "properties": { Chris@18: "meta": { Chris@18: "$ref": "#/definitions/meta" Chris@18: }, Chris@18: "links": { Chris@18: "$ref": "#/definitions/links" Chris@18: }, Chris@18: "jsonapi": { Chris@18: "$ref": "#/definitions/jsonapi" Chris@18: } Chris@18: }, Chris@18: "additionalProperties": false Chris@18: }, Chris@18: Chris@18: "meta": { Chris@18: "description": "Non-standard meta-information that can not be represented as an attribute or relationship.", Chris@18: "type": "object", Chris@18: "additionalProperties": true Chris@18: }, Chris@18: "data": { Chris@18: "description": "The document's \"primary data\" is a representation of the resource or collection of resources targeted by a request.", Chris@18: "oneOf": [ Chris@18: { Chris@18: "$ref": "#/definitions/resource" Chris@18: }, Chris@18: { Chris@18: "description": "An array of resource objects, an array of resource identifier objects, or an empty array ([]), for requests that target resource collections.", Chris@18: "type": "array", Chris@18: "items": { Chris@18: "$ref": "#/definitions/resource" Chris@18: }, Chris@18: "uniqueItems": true Chris@18: }, Chris@18: { Chris@18: "description": "null if the request is one that might correspond to a single resource, but doesn't currently.", Chris@18: "type": "null" Chris@18: } Chris@18: ] Chris@18: }, Chris@18: "resource": { Chris@18: "description": "\"Resource objects\" appear in a JSON:API document to represent resources.", Chris@18: "type": "object", Chris@18: "required": [ Chris@18: "type", Chris@18: "id" Chris@18: ], Chris@18: "properties": { Chris@18: "type": { Chris@18: "type": "string" Chris@18: }, Chris@18: "id": { Chris@18: "type": "string" Chris@18: }, Chris@18: "attributes": { Chris@18: "$ref": "#/definitions/attributes" Chris@18: }, Chris@18: "relationships": { Chris@18: "$ref": "#/definitions/relationships" Chris@18: }, Chris@18: "links": { Chris@18: "$ref": "#/definitions/links" Chris@18: }, Chris@18: "meta": { Chris@18: "$ref": "#/definitions/meta" Chris@18: } Chris@18: }, Chris@18: "additionalProperties": false Chris@18: }, Chris@18: "relationshipLinks": { Chris@18: "description": "A resource object **MAY** contain references to other resource objects (\"relationships\"). Relationships may be to-one or to-many. Relationships can be specified by including a member in a resource's links object.", Chris@18: "type": "object", Chris@18: "properties": { Chris@18: "self": { Chris@18: "description": "A `self` member, whose value is a URL for the relationship itself (a \"relationship URL\"). This URL allows the client to directly manipulate the relationship. For example, it would allow a client to remove an `author` from an `article` without deleting the people resource itself.", Chris@18: "$ref": "#/definitions/link" Chris@18: }, Chris@18: "related": { Chris@18: "$ref": "#/definitions/link" Chris@18: } Chris@18: }, Chris@18: "additionalProperties": true Chris@18: }, Chris@18: "links": { Chris@18: "type": "object", Chris@18: "additionalProperties": { Chris@18: "$ref": "#/definitions/link" Chris@18: } Chris@18: }, Chris@18: "link": { Chris@18: "description": "A link **MUST** be represented as either: a string containing the link's URL or a link object.", Chris@18: "oneOf": [ Chris@18: { Chris@18: "description": "A string containing the link's URL.", Chris@18: "type": "string", Chris@18: "format": "uri-reference" Chris@18: }, Chris@18: { Chris@18: "type": "object", Chris@18: "required": [ Chris@18: "href" Chris@18: ], Chris@18: "properties": { Chris@18: "href": { Chris@18: "description": "A string containing the link's URL.", Chris@18: "type": "string", Chris@18: "format": "uri-reference" Chris@18: }, Chris@18: "meta": { Chris@18: "$ref": "#/definitions/meta" Chris@18: } Chris@18: } Chris@18: } Chris@18: ] Chris@18: }, Chris@18: Chris@18: "attributes": { Chris@18: "description": "Members of the attributes object (\"attributes\") represent information about the resource object in which it's defined.", Chris@18: "type": "object", Chris@18: "patternProperties": { Chris@18: "^(?!relationships$|links$|id$|type$)\\w[-\\w_]*$": { Chris@18: "description": "Attributes may contain any valid JSON value." Chris@18: } Chris@18: }, Chris@18: "additionalProperties": false Chris@18: }, Chris@18: Chris@18: "relationships": { Chris@18: "description": "Members of the relationships object (\"relationships\") represent references from the resource object in which it's defined to other resource objects.", Chris@18: "type": "object", Chris@18: "patternProperties": { Chris@18: "^(?!id$|type$)\\w[-\\w_]*$": { Chris@18: "properties": { Chris@18: "links": { Chris@18: "$ref": "#/definitions/relationshipLinks" Chris@18: }, Chris@18: "data": { Chris@18: "description": "Member, whose value represents \"resource linkage\".", Chris@18: "oneOf": [ Chris@18: { Chris@18: "$ref": "#/definitions/relationshipToOne" Chris@18: }, Chris@18: { Chris@18: "$ref": "#/definitions/relationshipToMany" Chris@18: } Chris@18: ] Chris@18: }, Chris@18: "meta": { Chris@18: "$ref": "#/definitions/meta" Chris@18: } Chris@18: }, Chris@18: "anyOf": [ Chris@18: {"required": ["data"]}, Chris@18: {"required": ["meta"]}, Chris@18: {"required": ["links"]} Chris@18: ], Chris@18: "additionalProperties": false Chris@18: } Chris@18: }, Chris@18: "additionalProperties": false Chris@18: }, Chris@18: "relationshipToOne": { Chris@18: "description": "References to other resource objects in a to-one (\"relationship\"). Relationships can be specified by including a member in a resource's links object.", Chris@18: "anyOf": [ Chris@18: { Chris@18: "$ref": "#/definitions/empty" Chris@18: }, Chris@18: { Chris@18: "$ref": "#/definitions/linkage" Chris@18: } Chris@18: ] Chris@18: }, Chris@18: "relationshipToMany": { Chris@18: "description": "An array of objects each containing \"type\" and \"id\" members for to-many relationships.", Chris@18: "type": "array", Chris@18: "items": { Chris@18: "$ref": "#/definitions/linkage" Chris@18: }, Chris@18: "uniqueItems": true Chris@18: }, Chris@18: "empty": { Chris@18: "description": "Describes an empty to-one relationship.", Chris@18: "type": "null" Chris@18: }, Chris@18: "linkage": { Chris@18: "description": "The \"type\" and \"id\" to non-empty members.", Chris@18: "type": "object", Chris@18: "required": [ Chris@18: "type", Chris@18: "id" Chris@18: ], Chris@18: "properties": { Chris@18: "type": { Chris@18: "type": "string" Chris@18: }, Chris@18: "id": { Chris@18: "type": "string" Chris@18: }, Chris@18: "meta": { Chris@18: "$ref": "#/definitions/meta" Chris@18: } Chris@18: }, Chris@18: "additionalProperties": false Chris@18: }, Chris@18: "pagination": { Chris@18: "type": "object", Chris@18: "properties": { Chris@18: "first": { Chris@18: "description": "The first page of data", Chris@18: "oneOf": [ Chris@18: { "$ref": "#/definitions/link" }, Chris@18: { "type": "null" } Chris@18: ] Chris@18: }, Chris@18: "last": { Chris@18: "description": "The last page of data", Chris@18: "oneOf": [ Chris@18: { "$ref": "#/definitions/link" }, Chris@18: { "type": "null" } Chris@18: ] Chris@18: }, Chris@18: "prev": { Chris@18: "description": "The previous page of data", Chris@18: "oneOf": [ Chris@18: { "$ref": "#/definitions/link" }, Chris@18: { "type": "null" } Chris@18: ] Chris@18: }, Chris@18: "next": { Chris@18: "description": "The next page of data", Chris@18: "oneOf": [ Chris@18: { "$ref": "#/definitions/link" }, Chris@18: { "type": "null" } Chris@18: ] Chris@18: } Chris@18: } Chris@18: }, Chris@18: Chris@18: "jsonapi": { Chris@18: "description": "An object describing the server's implementation", Chris@18: "type": "object", Chris@18: "properties": { Chris@18: "version": { Chris@18: "type": "string" Chris@18: }, Chris@18: "meta": { Chris@18: "$ref": "#/definitions/meta" Chris@18: } Chris@18: }, Chris@18: "additionalProperties": false Chris@18: }, Chris@18: Chris@18: "error": { Chris@18: "type": "object", Chris@18: "properties": { Chris@18: "id": { Chris@18: "description": "A unique identifier for this particular occurrence of the problem.", Chris@18: "type": "string" Chris@18: }, Chris@18: "links": { Chris@18: "$ref": "#/definitions/links" Chris@18: }, Chris@18: "status": { Chris@18: "description": "The HTTP status code applicable to this problem, expressed as a string value.", Chris@18: "type": "string" Chris@18: }, Chris@18: "code": { Chris@18: "description": "An application-specific error code, expressed as a string value.", Chris@18: "type": "string" Chris@18: }, Chris@18: "title": { Chris@18: "description": "A short, human-readable summary of the problem. It **SHOULD NOT** change from occurrence to occurrence of the problem, except for purposes of localization.", Chris@18: "type": "string" Chris@18: }, Chris@18: "detail": { Chris@18: "description": "A human-readable explanation specific to this occurrence of the problem.", Chris@18: "type": "string" Chris@18: }, Chris@18: "source": { Chris@18: "type": "object", Chris@18: "properties": { Chris@18: "pointer": { Chris@18: "description": "A JSON Pointer [RFC6901] to the associated entity in the request document [e.g. \"/data\" for a primary data object, or \"/data/attributes/title\" for a specific attribute].", Chris@18: "type": "string" Chris@18: }, Chris@18: "parameter": { Chris@18: "description": "A string indicating which query parameter caused the error.", Chris@18: "type": "string" Chris@18: } Chris@18: } Chris@18: }, Chris@18: "meta": { Chris@18: "$ref": "#/definitions/meta" Chris@18: } Chris@18: }, Chris@18: "additionalProperties": false Chris@18: } Chris@18: } Chris@18: }