-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjson-schema.yml
More file actions
185 lines (185 loc) · 5.71 KB
/
Copy pathjson-schema.yml
File metadata and controls
185 lines (185 loc) · 5.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
---
"$schema": https://json-schema.org/draft/2020-12/schema
title: JSON:API JSON Schema
description: This is a JSON Schema for responses in the JSON:API format. For more, see http://jsonapi.org.
type: object
required:
- data
properties:
data:
"$ref": "#/$defs/Data"
included:
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".
type: array
items:
"$ref": "#/$defs/Resource"
uniqueItems: true
meta:
"$ref": "#/$defs/Meta"
links:
description: Link members related to the primary data.
allOf:
- "$ref": "#/$defs/Links"
- "$ref": "#/$defs/Pagination"
additionalProperties: false
"$defs":
Meta:
description: Non-standard meta-information that can not be represented as an attribute
or relationship.
type: object
additionalProperties: true
Data:
description: The document's "primary data" is a representation of the resource
or collection of resources targeted by a request.
oneOf:
- "$ref": "#/$defs/Resource"
- description: An array of resource objects, an array of resource identifier objects,
or an empty array ([]), for requests that target resource collections.
type: array
items:
"$ref": "#/$defs/Resource"
uniqueItems: true
- description: null if the request is one that might correspond to a single resource,
but doesn't currently.
type: 'null'
Resource:
description: '"Resource objects" appear in a JSON:API document to represent resources.'
type: object
required:
- type
- id
properties:
type:
type: string
id:
type: string
attributes:
"$ref": "#/$defs/Attributes"
relationships:
"$ref": "#/$defs/Relationships"
links:
"$ref": "#/$defs/Links"
meta:
"$ref": "#/$defs/Meta"
additionalProperties: false
RelationshipLinks:
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.
type: object
properties:
self:
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.
"$ref": "#/$defs/Link"
related:
"$ref": "#/$defs/Link"
additionalProperties: true
Links:
type: object
additionalProperties:
"$ref": "#/$defs/Link"
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
- description: A string containing the link's URL.
type: string
format: uri-reference
Attributes:
description: Members of the attributes object ("attributes") represent information
about the resource object in which it's defined.
type: object
patternProperties:
"^(?!relationships$|links$|id$|type$)\\w[-\\w_]*$":
description: Attributes may contain any valid JSON value.
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:
"^(?!id$|type$)\\w[-\\w_]*$":
properties:
links:
"$ref": "#/$defs/RelationshipLinks"
data:
description: Member, whose value represents "resource linkage".
oneOf:
- "$ref": "#/$defs/RelationshipToOne"
- "$ref": "#/$defs/RelationshipToMany"
meta:
"$ref": "#/$defs/Meta"
anyOf:
- required:
- data
- required:
- meta
- required:
- links
additionalProperties: false
additionalProperties: false
RelationshipToOne:
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.
anyOf:
- "$ref": "#/$defs/Empty"
- "$ref": "#/$defs/Linkage"
RelationshipToMany:
description: An array of objects each containing "type" and "id" members for to-many
relationships.
type: array
items:
"$ref": "#/$defs/Linkage"
uniqueItems: true
Empty:
description: Describes an empty to-one relationship.
type: 'null'
Linkage:
description: The "type" and "id" to non-empty members.
type: object
required:
- type
- id
properties:
type:
type: string
id:
type: string
meta:
"$ref": "#/$defs/Meta"
additionalProperties: false
Pagination:
type: object
properties:
first:
description: The first page of data
oneOf:
- type: string
format: uri-reference
- type: 'null'
last:
description: The last page of data
oneOf:
- type: string
format: uri-reference
- type: 'null'
prev:
description: The previous page of data
oneOf:
- type: string
format: uri-reference
- type: 'null'
next:
description: The next page of data
oneOf:
- type: string
format: uri-reference
- type: 'null'