-
Notifications
You must be signed in to change notification settings - Fork 890
Update JSON Schema to be v1.0 compliant #1555
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,17 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$id": "https://jsonapi.org/schemas/spec/v1.0/draft", | ||
"$comment": "The $id URI should be modified before releasing. This URI does not need to be network addressable. It is an ID only.", | ||
"title": "JSON:API Schema", | ||
"description": "This is a schema for responses in the JSON:API format. For more, see http://jsonapi.org", | ||
"description": "A JSON Schema downloaded from jsonapi.org/schema on 2020-02-22 - modified to align with the specification. Additionaly, this schema only validates RESPONSES from a request. Validating request payloads requires slightly different constraints.", | ||
"oneOf": [ | ||
{ | ||
"$ref": "#/definitions/success" | ||
}, | ||
{ | ||
"$ref": "#/definitions/failure" | ||
}, | ||
{ | ||
"$ref": "#/definitions/info" | ||
} | ||
], | ||
|
||
"definitions": { | ||
"success": { | ||
"type": "object", | ||
|
@@ -37,14 +35,7 @@ | |
}, | ||
"links": { | ||
"description": "Link members related to the primary data.", | ||
"allOf": [ | ||
{ | ||
"$ref": "#/definitions/links" | ||
}, | ||
{ | ||
"$ref": "#/definitions/pagination" | ||
} | ||
] | ||
"$ref": "#/definitions/links" | ||
}, | ||
"jsonapi": { | ||
"$ref": "#/definitions/jsonapi" | ||
|
@@ -77,25 +68,6 @@ | |
}, | ||
"additionalProperties": false | ||
}, | ||
"info": { | ||
"type": "object", | ||
"required": [ | ||
"meta" | ||
], | ||
"properties": { | ||
"meta": { | ||
"$ref": "#/definitions/meta" | ||
}, | ||
"links": { | ||
"$ref": "#/definitions/links" | ||
}, | ||
"jsonapi": { | ||
"$ref": "#/definitions/jsonapi" | ||
} | ||
}, | ||
"additionalProperties": false | ||
}, | ||
|
||
"meta": { | ||
"description": "Non-standard meta-information that can not be represented as an attribute or relationship.", | ||
"type": "object", | ||
|
@@ -142,7 +114,7 @@ | |
"$ref": "#/definitions/relationships" | ||
}, | ||
"links": { | ||
"$ref": "#/definitions/links" | ||
"$ref": "#/definitions/relationshipLinks" | ||
}, | ||
"meta": { | ||
"$ref": "#/definitions/meta" | ||
|
@@ -160,23 +132,43 @@ | |
}, | ||
"related": { | ||
"$ref": "#/definitions/link" | ||
}, | ||
"pagination": { | ||
"$ref": "#/definitions/pagination" | ||
} | ||
}, | ||
"additionalProperties": true | ||
}, | ||
"links": { | ||
"type": "object", | ||
"additionalProperties": { | ||
"$ref": "#/definitions/link" | ||
} | ||
}, | ||
"links": { | ||
"type": "object", | ||
"allOf": [ | ||
{ | ||
"properties": { | ||
"first": true, | ||
"last": true, | ||
"next": true, | ||
"prev": true | ||
}, | ||
"additionalProperties": { | ||
"$ref": "#/definitions/link" | ||
} | ||
}, | ||
{ | ||
"$ref": "#/definitions/pagination" | ||
} | ||
] | ||
}, | ||
"link": { | ||
"description": "A link **MUST** be represented as either: a string containing the link's URL or a link object.", | ||
"oneOf": [ | ||
{ | ||
"description": "A string containing the link's URL.", | ||
"type": "string", | ||
"format": "uri-reference" | ||
"format": "uri", | ||
"$comment": "URI regex as per https://tools.ietf.org/html/rfc3986#appendix-B", | ||
"pattern": "^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?" | ||
}, | ||
{ | ||
"type": "object", | ||
|
@@ -187,7 +179,9 @@ | |
"href": { | ||
"description": "A string containing the link's URL.", | ||
"type": "string", | ||
"format": "uri-reference" | ||
"format": "uri", | ||
"$comment": "URI regex as per https://tools.ietf.org/html/rfc3986#appendix-B", | ||
"pattern": "^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?" | ||
}, | ||
"meta": { | ||
"$ref": "#/definitions/meta" | ||
|
@@ -196,7 +190,6 @@ | |
} | ||
] | ||
}, | ||
|
||
"attributes": { | ||
"description": "Members of the attributes object (\"attributes\") represent information about the resource object in which it's defined.", | ||
"type": "object", | ||
|
@@ -206,16 +199,22 @@ | |
} | ||
}, | ||
"not": { | ||
"$comment": "This is what the specification requires, but it seems bad. https://github.com/json-api/json-api/issues/1553", | ||
"anyOf": [ | ||
{"required": ["relationships"]}, | ||
{"required": ["links"]}, | ||
{"required": ["id"]}, | ||
{"required": ["type"]} | ||
{ | ||
"required": [ | ||
"relationships" | ||
] | ||
}, | ||
{ | ||
"required": [ | ||
"links" | ||
] | ||
} | ||
] | ||
}, | ||
"additionalProperties": false | ||
}, | ||
|
||
"relationships": { | ||
"description": "Members of the relationships object (\"relationships\") represent references from the resource object in which it's defined to other resource objects.", | ||
"type": "object", | ||
|
@@ -241,16 +240,22 @@ | |
} | ||
}, | ||
"anyOf": [ | ||
{"required": ["data"]}, | ||
{"required": ["meta"]}, | ||
{"required": ["links"]} | ||
{ | ||
"required": [ | ||
"data" | ||
] | ||
}, | ||
{ | ||
"required": [ | ||
"meta" | ||
] | ||
}, | ||
{ | ||
"required": [ | ||
"links" | ||
] | ||
} | ||
], | ||
"not": { | ||
"anyOf": [ | ||
{"required": ["id"]}, | ||
{"required": ["type"]} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should this be moved up one level instead of removed to satisfy the restriction
|
||
] | ||
}, | ||
"additionalProperties": false | ||
} | ||
}, | ||
|
@@ -305,34 +310,49 @@ | |
"first": { | ||
"description": "The first page of data", | ||
"oneOf": [ | ||
{ "$ref": "#/definitions/link" }, | ||
{ "type": "null" } | ||
{ | ||
"$ref": "#/definitions/link" | ||
}, | ||
{ | ||
"type": "null" | ||
} | ||
] | ||
}, | ||
"last": { | ||
"description": "The last page of data", | ||
"oneOf": [ | ||
{ "$ref": "#/definitions/link" }, | ||
{ "type": "null" } | ||
{ | ||
"$ref": "#/definitions/link" | ||
}, | ||
{ | ||
"type": "null" | ||
} | ||
] | ||
}, | ||
"prev": { | ||
"description": "The previous page of data", | ||
"oneOf": [ | ||
{ "$ref": "#/definitions/link" }, | ||
{ "type": "null" } | ||
{ | ||
"$ref": "#/definitions/link" | ||
}, | ||
{ | ||
"type": "null" | ||
} | ||
] | ||
}, | ||
"next": { | ||
"description": "The next page of data", | ||
"oneOf": [ | ||
{ "$ref": "#/definitions/link" }, | ||
{ "type": "null" } | ||
{ | ||
"$ref": "#/definitions/link" | ||
}, | ||
{ | ||
"type": "null" | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
|
||
"jsonapi": { | ||
"description": "An object describing the server's implementation", | ||
"type": "object", | ||
|
@@ -346,13 +366,13 @@ | |
}, | ||
"additionalProperties": false | ||
}, | ||
|
||
"error": { | ||
"type": "object", | ||
"properties": { | ||
"id": { | ||
"description": "A unique identifier for this particular occurrence of the problem.", | ||
"type": "string" | ||
"type": "string", | ||
"$comment": "The spec doesn't specify that this MUST be a string, so this could be changed to additionally allow numbers" | ||
Comment on lines
+374
to
+375
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we also allow |
||
}, | ||
"links": { | ||
"$ref": "#/definitions/links" | ||
|
@@ -378,7 +398,8 @@ | |
"properties": { | ||
"pointer": { | ||
"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].", | ||
"type": "string" | ||
"type": "string", | ||
"pattern": "^(?:\\/(?:[^~/]|~0|~1)*)*$" | ||
}, | ||
"parameter": { | ||
"description": "A string indicating which query parameter caused the error.", | ||
|
@@ -394,4 +415,3 @@ | |
} | ||
} | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would this then allow "id" and "type" as
attributes
member, would that violate one of the restrictions for fields?