Skip to content

Separate out JSON Schema into schema, schema-update, schema-create #1127

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
21 changes: 18 additions & 3 deletions schema
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 +114,19 @@
}
]
},
"resource": {

"newResource": {
"description": "\"Resource objects\" appear in a JSON API document to represent resources.",
"type": "object",
"required": [
"type",
"id"
"type"
],
"properties": {
"type": {
"type": "string"
},
"id": {
"description": "A server **MAY** accept a client-generated ID along with a request to create a resource. An ID **MUST** be specified with an id key, the value of which **MUST** be a universally unique identifier. The client **SHOULD** use a properly generated and formatted UUID as described in RFC 4122.",
"type": "string"
},
"attributes": {
Expand All @@ -143,6 +144,20 @@
},
"additionalProperties": false
},
"resource": {
"description": "\"Resource objects\" appear in a JSON API document to represent resources.",
"allOf": [
{
"$ref": "#/definitions/newResource"
},
{
"required": [
"type",
"id"
]
}
]
},

"links": {
"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.",
Expand Down
28 changes: 28 additions & 0 deletions schema-create
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "JSON API Schema",
"description": "This is a schema for clients creating resources in the JSON API format. For more, see http://jsonapi.org",
"type": "object",
"required": [
"data"
],
"properties": {
"data": {
"$ref": "#/definitions/newData"
},
"meta": {
"$ref": "http://jsonapi.org/schema#/definitions/meta"
},
"jsonapi": {
"$ref": "http://jsonapi.org/schema#/definitions/jsonapi"
}
},
"additionalProperties": false,

"definitions": {
"newData": {
"description": "A resource can be created by sending a `POST` request to a URL that represents a collection of resources. The request **MUST** include a single resource object as primary data.",
"$ref": "http://jsonapi.org/schema#/definitions/newResource"
}
}
}
36 changes: 36 additions & 0 deletions schema-update
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "JSON API Schema",
"description": "This is a schema for clients updating resources in the JSON API format. For more, see http://jsonapi.org",
"type": "object",
"required": [
"data"
],
"properties": {
"data": {
"$ref": "#/definitions/updateData"
},
"meta": {
"$ref": "http://jsonapi.org/schema#/definitions/meta"
},
"jsonapi": {
"$ref": "http://jsonapi.org/schema#/definitions/jsonapi"
}
},
"additionalProperties": false,

"definitions": {
"updateData": {
"description": "The `PATCH` request **MUST** include a single resource object as primary data. A relationshp can be cleared by sending `null` data.",
"oneOf": [
{
"description": "Used to remove a relationship.",
"type": "null"
},
{
"$ref": "http://jsonapi.org/schema#/definitions/resource"
}
]
}
}
}
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy