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