-
Notifications
You must be signed in to change notification settings - Fork 71
/
siren.schema.json
371 lines (371 loc) · 15.2 KB
/
siren.schema.json
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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
{
"id": "http://sirenspec.org/schema#",
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Entity",
"description": "An Entity is a URI-addressable resource that has properties and actions associated with it. It may contain sub-entities and navigational links.",
"type": "object",
"properties": {
"class": {
"description": "Describes the nature of an entity's content based on the current representation. Possible values are implementation-dependent and should be documented.",
"type": "array",
"items": {
"type": "string"
}
},
"title": {
"description": "Descriptive text about the entity.",
"type": "string"
},
"properties": {
"description": "A set of key-value pairs that describe the state of an entity.",
"type": "object"
},
"entities": {
"description": "A collection of related sub-entities. If a sub-entity contains an href value, it should be treated as an embedded link. Clients may choose to optimistically load embedded links. If no href value exists, the sub-entity is an embedded entity representation that contains all the characteristics of a typical entity. One difference is that a sub-entity MUST contain a rel attribute to describe its relationship to the parent entity.",
"type": "array",
"items": {
"$ref": "#/definitions/SubEntity"
}
},
"actions": {
"description": "A collection of actions; actions show available behaviors an entity exposes.",
"type": "array",
"items": {
"$ref": "#/definitions/Action"
}
},
"links": {
"description": "A collection of items that describe navigational links, distinct from entity relationships. Link items should contain a `rel` attribute to describe the relationship and an `href` attribute to point to the target URI. Entities should include a link `rel` to `self`.",
"type": "array",
"items": {
"$ref": "#/definitions/Link"
}
}
},
"definitions": {
"SubEntity": {
"anyOf": [
{ "$ref": "#/definitions/EmbeddedLinkSubEntity" },
{ "$ref": "#/definitions/EmbeddedRepresentationSubEntity" }
]
},
"EmbeddedLinkSubEntity": {
"type": "object",
"required": [ "rel", "href" ],
"properties": {
"class": {
"description": "Describes the nature of an entity's content based on the current representation. Possible values are implementation-dependent and should be documented.",
"type": "array",
"items": {
"type": "string"
}
},
"rel": {
"description": "Defines the relationship of the sub-entity to its parent, per Web Linking (RFC5899).",
"type": "array",
"items": {
"$ref": "#/definitions/RelValue"
},
"minItems": 1
},
"href": {
"description": "The URI of the linked sub-entity.",
"type": "string",
"format": "uri"
},
"type": {
"$ref": "#/definitions/MediaType"
},
"title": {
"description": "Descriptive text about the entity.",
"type": "string"
}
}
},
"EmbeddedRepresentationSubEntity": {
"allOf": [
{
"$ref": "#"
},
{
"required": [ "rel" ],
"properties": {
"rel": {
"description": "Defines the relationship of the sub-entity to its parent, per Web Linking (RFC5899).",
"type": "array",
"items": {
"$ref": "#/definitions/RelValue"
},
"minItems": 1
}
}
}
]
},
"Action": {
"description": "Actions show available behaviors an entity exposes.",
"type": "object",
"required": [
"name",
"href"
],
"properties": {
"class": {
"description": "Describes the nature of an action based on the current representation. Possible values are implementation-dependent and should be documented.",
"type": "array",
"items": {
"type": "string"
}
},
"name": {
"description": "A string that identifies the action to be performed. Action names MUST be unique within the set of actions for an entity. The behaviour of clients when parsing a Siren document that violates this constraint is undefined.",
"type": "string"
},
"method": {
"description": "An enumerated attribute mapping to a protocol method. For HTTP, these values may be GET, PUT, POST, DELETE, or PATCH. As new methods are introduced, this list can be extended. If this attribute is omitted, GET should be assumed.",
"type": "string",
"enum": [
"DELETE",
"GET",
"PATCH",
"POST",
"PUT"
],
"default": "GET"
},
"href": {
"description": "The URI of the action.",
"type": "string",
"format": "uri"
},
"title": {
"description": "Descriptive text about the action.",
"type": "string"
},
"type": {
"description": "The encoding type for the request. When omitted and the fields attribute exists, the default value is `application/x-www-form-urlencoded`.",
"type": "string",
"default": "application/x-www-form-urlencoded"
},
"fields": {
"description": "A collection of fields.",
"type": "array",
"items": {
"$ref": "#/definitions/Field"
}
}
}
},
"Field": {
"description": "Fields represent controls inside of actions.",
"type": "object",
"required": [
"name"
],
"properties": {
"name": {
"description": "A name describing the control. Field names MUST be unique within the set of fields for an action. The behaviour of clients when parsing a Siren document that violates this constraint is undefined.",
"type": "string"
},
"type": {
"description": "The input type of the field. This is a subset of the input types specified by HTML5.",
"type": "string",
"default": "text",
"enum": [
"hidden",
"text",
"search",
"tel",
"url",
"email",
"password",
"datetime",
"date",
"month",
"week",
"time",
"datetime-local",
"number",
"range",
"color",
"checkbox",
"radio",
"file"
]
},
"title": {
"description": "Textual annotation of a field. Clients may use this as a label.",
"type": "string"
},
"value": {
"description": "A value assigned to the field. May be a scalar value or a list of value objects.",
"oneOf": [
{
"type": [ "string", "number" ]
},
{
"type": "array",
"items": {
"$ref": "#/definitions/FieldValueObject"
}
}
]
}
}
},
"FieldValueObject": {
"description": "Value objects represent multiple selectable field values. Use in conjunction with field `\"type\" = \"radio\"` and `\"type\" = \"checkbox\"` to express that zero, one or many out of several possible values may be sent back to the server.",
"type": "object",
"required": [ "value" ],
"properties": {
"title": {
"description": "Textual description of a field value.",
"type": "string"
},
"value": {
"description": "Possible value for the field.",
"type": [ "string", "number" ]
},
"selected": {
"description": "A value object with a `\"selected\" = true` attribute indicates that this value should be considered preselected by the client. When missing, the default value is `false`.",
"type": "boolean",
"default": false
}
}
},
"Link": {
"description": "Links represent navigational transitions.",
"type": "object",
"required": [
"rel",
"href"
],
"properties": {
"class": {
"description": "Describes aspects of the link based on the current representation. Possible values are implementation-dependent and should be documented.",
"type": "array",
"items": {
"type": "string"
}
},
"title": {
"description": "Text describing the nature of a link.",
"type": "string"
},
"rel": {
"description": "Defines the relationship of the link to its entity, per Web Linking (RFC5988).",
"type": "array",
"items": {
"$ref": "#/definitions/RelValue"
}
},
"href": {
"description": "The URI of the linked resource.",
"type": "string",
"format": "uri"
},
"type": {
"$ref": "#/definitions/MediaType"
}
}
},
"MediaType": {
"description": "Defines media type of the linked resource, per Web Linking (RFC5988). For the syntax, see RFC2045 (section 5.1), RFC4288 (section 4.2), RFC6838 (section 4.2)",
"type": "string",
"pattern": "^(application|audio|image|message|model|multipart|text|video)\\/([A-Z]|[a-z]|[0-9]|[\\!\\#\\$\\&\\.\\+\\-\\^\\_]){1,127}(; ?(([\\!\\#\\$\\%\\&\\'\\(\\)\\*\\+-\\.\\/]|[0-9]|[A-Z]|[\\^\\_\\`\\]\\|]|[a-z]|[\\|\\~])+)+=((([\\!\\#\\$\\%\\&\\'\\(\\)\\*\\+-\\.\\/]|[0-9]|[A-Z]|[\\^\\_\\`\\]\\|]|[a-z]|[\\|\\~])+)|\"([\\!\\#\\$\\%\\&\\.\\(\\)\\*\\+\\,\\-\\.\\/]|[0-9]|[\\:\\;\\<\\=\\>\\?\\@]|[A-Z]|[\\[\\\\\\]\\^\\_\\`]|[a-z]|[\\{\\|\\}\\~])+\"))*$"
},
"RelValue": {
"anyOf": [
{
"type": "string",
"format": "uri"
},
{
"type": "string",
"enum": [
"about",
"alternate",
"appendix",
"archives",
"author",
"blocked-by",
"bookmark",
"canonical",
"chapter",
"collection",
"contents",
"convertedFrom",
"copyright",
"create-form",
"current",
"derivedfrom",
"describedby",
"describes",
"disclosure",
"dns-prefetch",
"duplicate",
"edit",
"edit-form",
"edit-media",
"enclosure",
"first",
"glossary",
"help",
"hosts",
"hub",
"icon",
"index",
"item",
"last",
"latest-version",
"license",
"lrdd",
"memento",
"monitor",
"monitor-group",
"next",
"next-archive",
"nofollow",
"noreferrer",
"original",
"payment",
"pingback",
"preconnect",
"predecessor-version",
"prefetch",
"preload",
"prerender",
"prev",
"preview",
"previous",
"prev-archive",
"privacy-policy",
"profile",
"related",
"restconf",
"replies",
"search",
"section",
"self",
"service",
"start",
"stylesheet",
"subsection",
"successor-version",
"tag",
"terms-of-service",
"timegate",
"timemap",
"type",
"up",
"version-history",
"via",
"webmention",
"working-copy",
"working-copy-of"
]
}
]
}
}
}