Debian Codegraph @

externals/OPTIMADE/schemas/src/json-schema/v1.2/jsonapi.json

raw
1 {
2 "$schema": "http://json-schema.org/draft-06/schema#",
3 "title": "JSON:API Schema",
4 "description": "This is a schema for responses in the JSON:API format. For more, see http://jsonapi.org",
5 "oneOf": [
6 {
7 "$ref": "#/definitions/success"
8 },
9 {
10 "$ref": "#/definitions/failure"
11 },
12 {
13 "$ref": "#/definitions/info"
14 }
15 ],
16
17 "definitions": {
18 "success": {
19 "type": "object",
20 "required": [
21 "data"
22 ],
23 "properties": {
24 "data": {
25 "$ref": "#/definitions/data"
26 },
27 "included": {
28 "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\".",
29 "type": "array",
30 "items": {
31 "$ref": "#/definitions/resource"
32 },
33 "uniqueItems": true
34 },
35 "meta": {
36 "$ref": "#/definitions/meta"
37 },
38 "links": {
39 "description": "Link members related to the primary data.",
40 "allOf": [
41 {
42 "$ref": "#/definitions/links"
43 },
44 {
45 "$ref": "#/definitions/pagination"
46 }
47 ]
48 },
49 "jsonapi": {
50 "$ref": "#/definitions/jsonapi"
51 }
52 },
53 "additionalProperties": false
54 },
55 "failure": {
56 "type": "object",
57 "required": [
58 "errors"
59 ],
60 "properties": {
61 "errors": {
62 "type": "array",
63 "items": {
64 "$ref": "#/definitions/error"
65 },
66 "uniqueItems": true
67 },
68 "meta": {
69 "$ref": "#/definitions/meta"
70 },
71 "jsonapi": {
72 "$ref": "#/definitions/jsonapi"
73 },
74 "links": {
75 "$ref": "#/definitions/links"
76 }
77 },
78 "additionalProperties": false
79 },
80 "info": {
81 "type": "object",
82 "required": [
83 "meta"
84 ],
85 "properties": {
86 "meta": {
87 "$ref": "#/definitions/meta"
88 },
89 "links": {
90 "$ref": "#/definitions/links"
91 },
92 "jsonapi": {
93 "$ref": "#/definitions/jsonapi"
94 }
95 },
96 "additionalProperties": false
97 },
98
99 "meta": {
100 "description": "Non-standard meta-information that can not be represented as an attribute or relationship.",
101 "type": "object",
102 "additionalProperties": true
103 },
104 "data": {
105 "description": "The document's \"primary data\" is a representation of the resource or collection of resources targeted by a request.",
106 "oneOf": [
107 {
108 "$ref": "#/definitions/resource"
109 },
110 {
111 "description": "An array of resource objects, an array of resource identifier objects, or an empty array ([]), for requests that target resource collections.",
112 "type": "array",
113 "items": {
114 "$ref": "#/definitions/resource"
115 },
116 "uniqueItems": true
117 },
118 {
119 "description": "null if the request is one that might correspond to a single resource, but doesn't currently.",
120 "type": "null"
121 }
122 ]
123 },
124 "resource": {
125 "description": "\"Resource objects\" appear in a JSON:API document to represent resources.",
126 "type": "object",
127 "required": [
128 "type",
129 "id"
130 ],
131 "properties": {
132 "type": {
133 "type": "string"
134 },
135 "id": {
136 "type": "string"
137 },
138 "attributes": {
139 "$ref": "#/definitions/attributes"
140 },
141 "relationships": {
142 "$ref": "#/definitions/relationships"
143 },
144 "links": {
145 "$ref": "#/definitions/links"
146 },
147 "meta": {
148 "$ref": "#/definitions/meta"
149 }
150 },
151 "additionalProperties": false
152 },
153 "relationshipLinks": {
154 "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.",
155 "type": "object",
156 "properties": {
157 "self": {
158 "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.",
159 "$ref": "#/definitions/link"
160 },
161 "related": {
162 "$ref": "#/definitions/link"
163 }
164 },
165 "additionalProperties": true
166 },
167 "links": {
168 "type": "object",
169 "additionalProperties": {
170 "$ref": "#/definitions/link"
171 }
172 },
173 "link": {
174 "description": "A link **MUST** be represented as either: a string containing the link's URL or a link object.",
175 "oneOf": [
176 {
177 "description": "A string containing the link's URL.",
178 "type": "string",
179 "format": "uri-reference"
180 },
181 {
182 "type": "object",
183 "required": [
184 "href"
185 ],
186 "properties": {
187 "href": {
188 "description": "A string containing the link's URL.",
189 "type": "string",
190 "format": "uri-reference"
191 },
192 "meta": {
193 "$ref": "#/definitions/meta"
194 }
195 }
196 }
197 ]
198 },
199
200 "attributes": {
201 "description": "Members of the attributes object (\"attributes\") represent information about the resource object in which it's defined.",
202 "type": "object",
203 "patternProperties": {
204 "^[a-zA-Z0-9](?:[-\\w]*[a-zA-Z0-9])?$": {
205 "description": "Attributes may contain any valid JSON value."
206 }
207 },
208 "not": {
209 "anyOf": [
210 {"required": ["relationships"]},
211 {"required": ["links"]},
212 {"required": ["id"]},
213 {"required": ["type"]}
214 ]
215 },
216 "additionalProperties": false
217 },
218
219 "relationships": {
220 "description": "Members of the relationships object (\"relationships\") represent references from the resource object in which it's defined to other resource objects.",
221 "type": "object",
222 "patternProperties": {
223 "^[a-zA-Z0-9](?:[-\\w]*[a-zA-Z0-9])?$": {
224 "properties": {
225 "links": {
226 "$ref": "#/definitions/relationshipLinks"
227 },
228 "data": {
229 "description": "Member, whose value represents \"resource linkage\".",
230 "oneOf": [
231 {
232 "$ref": "#/definitions/relationshipToOne"
233 },
234 {
235 "$ref": "#/definitions/relationshipToMany"
236 }
237 ]
238 },
239 "meta": {
240 "$ref": "#/definitions/meta"
241 }
242 },
243 "anyOf": [
244 {"required": ["data"]},
245 {"required": ["meta"]},
246 {"required": ["links"]}
247 ],
248 "not": {
249 "anyOf": [
250 {"required": ["id"]},
251 {"required": ["type"]}
252 ]
253 },
254 "additionalProperties": false
255 }
256 },
257 "additionalProperties": false
258 },
259 "relationshipToOne": {
260 "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.",
261 "anyOf": [
262 {
263 "$ref": "#/definitions/empty"
264 },
265 {
266 "$ref": "#/definitions/linkage"
267 }
268 ]
269 },
270 "relationshipToMany": {
271 "description": "An array of objects each containing \"type\" and \"id\" members for to-many relationships.",
272 "type": "array",
273 "items": {
274 "$ref": "#/definitions/linkage"
275 },
276 "uniqueItems": true
277 },
278 "empty": {
279 "description": "Describes an empty to-one relationship.",
280 "type": "null"
281 },
282 "linkage": {
283 "description": "The \"type\" and \"id\" to non-empty members.",
284 "type": "object",
285 "required": [
286 "type",
287 "id"
288 ],
289 "properties": {
290 "type": {
291 "type": "string"
292 },
293 "id": {
294 "type": "string"
295 },
296 "meta": {
297 "$ref": "#/definitions/meta"
298 }
299 },
300 "additionalProperties": false
301 },
302 "pagination": {
303 "type": "object",
304 "properties": {
305 "first": {
306 "description": "The first page of data",
307 "oneOf": [
308 { "$ref": "#/definitions/link" },
309 { "type": "null" }
310 ]
311 },
312 "last": {
313 "description": "The last page of data",
314 "oneOf": [
315 { "$ref": "#/definitions/link" },
316 { "type": "null" }
317 ]
318 },
319 "prev": {
320 "description": "The previous page of data",
321 "oneOf": [
322 { "$ref": "#/definitions/link" },
323 { "type": "null" }
324 ]
325 },
326 "next": {
327 "description": "The next page of data",
328 "oneOf": [
329 { "$ref": "#/definitions/link" },
330 { "type": "null" }
331 ]
332 }
333 }
334 },
335
336 "jsonapi": {
337 "description": "An object describing the server's implementation",
338 "type": "object",
339 "properties": {
340 "version": {
341 "type": "string"
342 },
343 "meta": {
344 "$ref": "#/definitions/meta"
345 }
346 },
347 "additionalProperties": false
348 },
349
350 "error": {
351 "type": "object",
352 "properties": {
353 "id": {
354 "description": "A unique identifier for this particular occurrence of the problem.",
355 "type": "string"
356 },
357 "links": {
358 "$ref": "#/definitions/links"
359 },
360 "status": {
361 "description": "The HTTP status code applicable to this problem, expressed as a string value.",
362 "type": "string"
363 },
364 "code": {
365 "description": "An application-specific error code, expressed as a string value.",
366 "type": "string"
367 },
368 "title": {
369 "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.",
370 "type": "string"
371 },
372 "detail": {
373 "description": "A human-readable explanation specific to this occurrence of the problem.",
374 "type": "string"
375 },
376 "source": {
377 "type": "object",
378 "properties": {
379 "pointer": {
380 "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].",
381 "type": "string"
382 },
383 "parameter": {
384 "description": "A string indicating which query parameter caused the error.",
385 "type": "string"
386 }
387 }
388 },
389 "meta": {
390 "$ref": "#/definitions/meta"
391 }
392 },
393 "additionalProperties": false
394 }
395 }
396 }
397