8000 Add JSON Schema that is v1.1 compliant by VGirol · Pull Request #1603 · json-api/json-api · GitHub
[go: up one dir, main page]

Skip to content

Add JSON Schema that is v1.1 compliant #1603

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

Open
wants to merge 11 commits into
base: gh-pages
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add JSON Schema that is v1.1 compliant
  • Loading branch information
VGirol committed Jan 18, 2022
commit 966499acb6f72b6fc1a9e39fe6acba7fd748ad1f
574 changes: 574 additions & 0 deletions _schemas/1.1/schema.json

Large diffs are not rendered by default.

140 changes: 140 additions & 0 deletions _schemas/1.1/schema_creation_resource.json
< 8000 div class="file-actions pt-0 mb-md-0 mb-2 ml-md-2 flex-shrink-0 flex-md-justify-end">
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://jsonapi.org/schemas/spec/v1.1/draft/Creation/Resource",
"$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 for POST request",
"description": "This schema only validates a request for POSTing a new resource.",
"required": [
"data"
],
"properties": {
"data": {
"$ref": "#/definitions/resource"
},
"included": {
"$ref": "https://jsonapi.org/schemas/spec/v1.1/draft#/definitions/included"
},
"jsonapi": {
"$ref": "https://jsonapi.org/schemas/spec/v1.1/draft#/definitions/jsonapi"
},
"links": {
"description": "Link members related to the primary data.",
"$ref": "https://jsonapi.org/schemas/spec/v1.1/draft#/definitions/topLevelLinks"
},
"meta": {
"$ref": "https://jsonapi.org/schemas/spec/v1.1/draft#/definitions/meta"
}
},
"dependencies": {
"included": ["data"]
},
"additionalProperties": false,
"definitions": {
"relationship": {
"type": "object",
"properties": {
"links": {
"$ref": "#/definitions/relationshipLinks"
},
"data": {
"$ref": "#/definitions/linkage"
},
"meta": {
"$ref": "#/definitions/meta"
}
},
"required": [
"data"
],
"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",
"patternProperties": {
"^[a-zA-Z0-9]{1}(?:[-\\w]*[a-zA-Z0-9])?$": {
"$ref": "#/definitions/relationship"
}
},
"not": {
"anyOf": [
{
"required": [
"type"
]
},
{
"required": [
"id"
]
}
]
},
"additionalProperties": false
},
"resource": {
"description": "\"Resource objects\" appear in a JSON:API document to represent resources.",
"$comment": "The id member is not required when the resource object originates at the client and represents a new resource to be created on the server.",
"type": "object",
"allOf": [
{
"$ref": "#/definitions/resourceIdentification"
}
],
"properties": {
"id": true,
"type": true,
"lid": true,
"attributes": {
"$ref": "https://jsonapi.org/schemas/spec/v1.1/draft#/definitions/attributes"
},
"links": {
"$ref": "https://jsonapi.org/schemas/spec/v1.1/draft#/definitions/resourceLinks"
},
"meta": {
"$ref": "https://jsonapi.org/schemas/spec/v1.1/draft#/definitions/meta"
},
"relationships": {
"$ref": "#/definitions/relationships"
}
},
"additionalProperties": false
},
"resourceIdentification": {
"type": "object",
"required": [
"type"
],
"properties": {
"type": {
"type": "string",
"pattern": "^[a-zA-Z0-9]{1}(?:[-\\w]*[a-zA-Z0-9])?$"
},
"id": {
"type": "string"
},
"lid": {
"type": "string"
}
}
},
"resourceIdentifier": {
"description": "The \"type\" and \"id\" to non-empty members.",
"type": "object",
"allOf": [
{
"$ref": "#/definitions/resourceIdentification"
}
],
"properties": {
"id": true,
"type": true,
"lid": true,
"meta": {
"$ref": "https://jsonapi.org/schemas/spec/v1.1/draft#/definitions/meta"
}
},
"additionalProperties": false
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"data": {
"type": "article",
"lid": 6,
"attributes": {
"title": "PHP is so crazy !"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"data": {
"type": "article",
"lid": "local_id",
"attributes": {
"title": "PHP is so crazy !"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"data": [
{
"type": "article",
"lid": 6
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"data": [
{
"type": "article",
"lid": "local_id"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"errors": [
{}
]
}
16 c F438 hanges: 16 additions & 0 deletions _schemas/1.1/tests/response/invalid/errors/invalid_error_objects.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"errors": [
{
"id": "0",
"status": "400",
"code": "4",
"title": "Oh no!",
"detail": "something",
"source": {
"header": {
"wrong": "not a string"
}
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"meta": {
"something": "wrong"
},
"jsonapi": {
"version": "1.0",
"ext": "error"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"meta": {
"something": "wrong"
},
"jsonapi": {
"version": "1.0",
"ext": [
"error"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"meta": {
"something": "wrong"
},
"jsonapi": {
"version": "1.0",
"profile": "error"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"meta": {
"something": "wrong"
},
"jsonapi": {
"version": "1.0",
"profile": [
"error"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"links": {
"self": {
"href": "http://example.com",
"rel": ["bad"],
"title": {
"attr": "wrong"
},
"type": 0,
"hreflang": ["bad"],
"describedby": {
"attr": "wrong"
}
}
},
"meta": {
"something": "is wrong"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"errors": [
{
"id": "1",
"links": {
"about": "http://www.example.com/errors/1"
},
"status": "400",
"code": "0x002",
"title": "human-readable summary of the problem",
"source": {
"pointer": "/data/id"
}
},
CB4C {
"id": "2",
"links": {
"about": "http://www.example.com/errors/2"
},
"status": "400",
"code": "0x008",
"title": "human-readable summary of the problem",
"source": {
"parameter": "include"
}
}
],
"meta": {
"anything": "valid"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"errors": [
{
"id": "1",
"links": {
"about": "http://www.example.com/errors/1",
"type": "http://www.example.com/errors/type"
},
"status": "400",
"code": "0x002",
"title": "human-readable summary of the problem",
"source": {
"pointer": "/data/id"
}
},
{
"id": "1",
"status": "400",
"code": "0x006",
"title": "human-readable summary of the problem",
"source": {
"header": "wrong-header"
}
}
]
}
Loading
0