forked from json-schema-org/json-schema-spec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jsonschema-hyperschema.xml
2754 lines (2697 loc) · 143 KB
/
jsonschema-hyperschema.xml
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
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0" encoding="US-ASCII"?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
<!ENTITY rfc2046 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2046.xml">
<!ENTITY rfc2119 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml">
<!ENTITY rfc3986 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.3986.xml">
<!ENTITY rfc4151 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4151.xml">
<!ENTITY rfc4287 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4287.xml">
<!ENTITY rfc5789 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.5789.xml">
<!ENTITY rfc6068 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6068.xml">
<!ENTITY rfc6570 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6570.xml">
<!ENTITY rfc6573 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6573.xml">
<!ENTITY rfc6901 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6901.xml">
<!ENTITY rfc7230 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.7230.xml">
<!ENTITY rfc7231 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.7231.xml">
<!ENTITY rfc7807 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.7807.xml">
<!ENTITY rfc8288 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.8288.xml">
<!ENTITY I-D.reschke-http-jfv SYSTEM "https://xml2rfc.tools.ietf.org/public/rfc/bibxml3/reference.I-D.draft-reschke-http-jfv-06.xml">
]>
<?rfc toc="yes"?>
<?rfc symrefs="yes"?>
<?rfc compact="yes"?>
<?rfc subcompact="no"?>
<?rfc strict="no"?>
<?rfc rfcedstyle="yes"?>
<?rfc comments="yes"?>
<?rfc inline="yes" ?>
<rfc category="info" docName="draft-handrews-json-schema-hyperschema-02" ipr="trust200902">
<front>
<title abbrev="JSON Hyper-Schema">
JSON Hyper-Schema: A Vocabulary for Hypermedia Annotation of JSON
</title>
<author fullname="Henry Andrews" initials="H" surname="Andrews" role="editor">
<address>
<postal>
<street></street>
<city>San Francisco</city>
<region>CA</region>
<country>USA</country>
</postal>
<email>henry@cloudflare.com</email>
</address>
</author>
<author fullname="Austin Wright" initials="A" surname="Wright" role="editor">
<address>
<email>aaa@bzfx.net</email>
</address>
</author>
<date year="2018" />
<workgroup>Internet Engineering Task Force</workgroup>
<keyword>JSON</keyword>
<keyword>Schema</keyword>
<keyword>JavaScript</keyword>
<keyword>Object</keyword>
<keyword>Notation</keyword>
<keyword>Hyper Schema</keyword>
<keyword>Hypermedia</keyword>
<abstract>
<t>
JSON Schema is a JSON-based format for describing JSON data using various
vocabularies. This document specifies a vocabulary for annotating JSON
documents with hyperlinks. These hyperlinks include attributes describing
how to manipulate and interact with remote resources through hypermedia
environments such as HTTP, as well as determining whether the link is usable
based on the instance value. The hyperlink serialization format described in
this document is also usable independent of JSON Schema.
</t>
</abstract>
<note title="Note to Readers">
<t>
The issues list for this draft can be found at
<eref target="https://github.com/json-schema-org/json-schema-spec/issues"/>.
</t>
<t>
For additional information, see
<eref target="http://json-schema.org/"/>.
</t>
<t>
To provide feedback, use this issue tracker, the communication methods listed on the
homepage, or email the document editors.
</t>
</note>
</front>
<middle>
<section title="Introduction">
<t>
JSON Hyper-Schema is a JSON Schema vocabulary for annotating JSON documents
with hyperlinks and instructions for processing and
manipulating remote JSON resources through hypermedia environments such as HTTP.
</t>
<t>
The term JSON Hyper-Schema is used to refer to a JSON Schema that uses these
keywords. The term "hyper-schema" on its own refers to a JSON Hyper-Schema
within the scope of this specification.
</t>
<t>
The primary mechanism introduced for specifying links is the Link Description
Object (LDO), which is a serialization of the abstract link model
defined in <xref target="RFC8288">RFC 8288, section 2</xref>.
</t>
<t>
This specification will use the concepts, syntax, and terminology defined by the
<xref target="json-schema">JSON Schema core</xref> and
<xref target="json-schema-validation">JSON Schema validation</xref> specifications.
It is advised that readers have a copy of these specifications.
</t>
</section>
<section title="Notational Conventions">
<t>
<!-- The text in this section has been copied from the official boilerplate,
and should not be modified.-->
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD",
"SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be
interpreted as described in <xref target="RFC2119">RFC 2119</xref>.
</t>
</section>
<section title="Overview">
<t>
JSON Hyper-Schema makes it possible to build hypermedia systems from JSON
documents by describing how to construct hyperlinks from instance data.
</t>
<t>
The combination of a JSON instance document and a valid application/schema+json
hyper-schema for that instance behaves as a single hypermedia representation.
By allowing this separation, hyper-schema-based systems can gracefully support
applications that expect plain JSON, while providing full hypermedia capabilities
for hyper-schema-aware applications and user agents.
</t>
<t>
User agents can detect the presence of hyper-schema by looking for
the application/schema+json media type and a "$schema" value that indicates the
presence of the hyper-schema vocabulary. A user agent can then use an
implementation of JSON Hyper-Schema to provide an interface to the
combination of the schema and instance documents as a single logical
representation of a resource, just as with any single-document hypermedia
representation format.
</t>
<t>
Hyper-schemas allow representations to take up fewer bytes on the wire, and
distribute the burden of link construction from the server to each client.
A user agent need not construct a link unless a client application requests
that link. JSON Hyper-Schema can also be used on the server side to generate
other link serializations or representation formats at runtime, or pre-emptively
follow links to facilitate server push usage.
</t>
<figure>
<preamble>
Here is an example hyper-schema that adds a single link, with the
IANA-registered link relation type "self", that is built from an instance
with one known object field named "id":
</preamble>
<artwork>
<![CDATA[{
"type": "object",
"properties": {
"id": {
"type": "number",
"readOnly": true
}
},
"links": [
{
"rel": "self",
"href": "thing/{id}"
}
]
}]]>
</artwork>
<postamble>
If the instance is {"id": 1234}, and its base URI according to
<xref target="RFC3986">RFC 3986 section 5.1</xref>, is
"https://api.example.com/", then "https://api.example.com/thing/1234"
is the resulting link's target URI.
</postamble>
</figure>
<section title="Terminology">
<t>
The terms "schema", "instance", and "meta-schema" are to be interpreted as
defined in the <xref target="json-schema">JSON Schema core specification</xref>.
</t>
<t>
The terms "applicable" and "attached" are to be interpreted as defined in
<xref target="json-schema-validation">Section 3 of the
JSON Schema validation specification</xref>.
</t>
<t>
The terms "link", "link context" (or "context"), "link target" (or "target"),
and "target attributes" are to be interpreted as defined in
<xref target="RFC8288">Section 2 of RFC 8288</xref>.
</t>
<t>
The term "user agent" is to be interpreted as defined in
<xref target="RFC7230">Section 2.1 of RFC 7230</xref>, generalized to apply
to any protocol that may be used in a hypermedia system rather than
specifically being an HTTP client.
</t>
<t>
This specification defines the following terms:
<list style="hanging">
<t hangText="JSON Hyper-Schema">
A JSON Schema using the keywords defined by this specification.
</t>
<t hangText="hyper-schema">
Within this document, the term "hyper-schema" always refers to
a JSON Hyper-Schema
</t>
<t hangText="link validity">
A valid link for an instance is one that is applicable to that
instance and does not fail any requirement imposed by the keywords
in the Link Description Object.
</t>
<t hangText="generic user agent">
A user agent which can be used to interact with any resource, from
any server, from among the standardized link relations, media types,
URI schemes, and protocols that it supports; though it may be
extendible to specially handle particular profiles of media types.
</t>
<t hangText="client application">
An application which uses a hypermedia system for a specific
purpose. Such an application may also be its own user agent,
or it may be built on top of a generic user agent. A client
application is programmed with knowledge of link relations,
media types, URI schemes, protocols, and data structures that
are specific to the application's domain.
</t>
<t hangText="client input">
Data provided through a user agent, and most often also through
a client application. Such data may be requested from a user
interactively, or provided before interaction in forms such as
command-line arguments, configuration files, or hardcoded values
in source code.
</t>
<t hangText="operation">
A specific use of a hyperlink, such as making a network request
(for a URI with a scheme such as "http://" that indicates a protocol)
or otherwise taking action based on a link (reading data from a
"data:" URI, or constructing an email message based on a "mailto:"
link). For protocols such as HTTP that support multiple methods,
each method is considered to be a separate operation on the same link.
</t>
</list>
</t>
</section>
<section title="Functionality">
<t>
A JSON Hyper-Schema implementation is able to take a hyper-schema, an
instance, and in some cases client input, and produce a set of fully
resolved valid links. As defined by
<xref target="RFC8288">RFC 8288, section 2</xref>,
a link consists of a context, a typed relation, a target, and optionally
additional target attributes.
</t>
<t>
The relation type and target attributes are taken directly from each link's
Link Description Object. The context and target identifiers are constructed
from some combination of URI Templates, instance data, and (in the case
of the target identifier) client input.
</t>
<t>
The target is always fully identified by a URI. Due to the lack of a URI
fragment identifier syntax for application/json and many other media types
that can be used with JSON Hyper-Schema, the context may be only partially
identified by a URI. In such cases, the remaining identification will be
provided as a JSON Pointer.
</t>
<t>
A few IANA-registered link relation types are given specific semantics in
a JSON Hyper-Schema document. A "self" link is used to interact with the
resource that the instance document represents, while "collection" and
"item" links identify resources for which collection-specific semantics
can be assumed.
</t>
</section>
</section>
<section title="Meta-Schemas and Output Schema">
<t>
The current URI for the JSON Hyper-Schema meta-schema is
<eref target="http://json-schema.org/draft-08/hyper-schema#"/>.
</t>
<t>
The <xref target="ldo">link description format</xref> can be used without JSON
Schema, and use of this format can be declared by referencing the normative
link description schema as the schema for the data structure that uses the links.
The URI of the normative link description schema is:
<eref target="http://json-schema.org/draft-08/links#"/>.
</t>
<t>
JSON Hyper-Schema implementations are free to provide output in any format.
However, a specific format is defined for use in the conformance test suite,
which is also used to illustrate points in the
<xref target="implementation">"Implementation Requirements"</xref>, and to
show the output generated by <xref target="examples">examples</xref>.
It is RECOMMENDED that implementations be capable of producing output
in this format to facilitated testing. The URI of the JSON Schema
describing the recommended output format is
<eref target="http://json-schema.org/draft-08/hyper-schema-output#"/>.
</t>
</section>
<section title="Schema Keywords">
<t>
Hyper-schema keywords from all schemas that are applicable to a position
in an instance, as defined by <xref target="json-schema-validation">Section
3 of JSON Schema validation</xref>, can be used with that instance.
</t>
<t>
When multiple subschemas are applicable to a given sub-instance, all "link"
arrays MUST be combined, in any order, into a single set. Each object
in the resulting set MUST retain its own list of applicable "base" values,
in resolution order, from the same schema and any parent schemas.
</t>
<t>
As with all JSON Schema keywords, all keywords described in this section
are optional. The minimal valid JSON Hyper-schema is the blank object.
</t>
<section title="base" anchor="base">
<t>
If present, this keyword MUST be first <xref target="uriTemplating">resolved as
a URI Template</xref>, and then MUST be resolved as a URI Reference against the
current URI base of the instance. The result MUST be set as the new URI
base for the instance while processing the sub-schema containing "base"
and all sub-schemas within it.
</t>
<t>
The process for resolving the "base" template can be different when being
resolved for use with "anchor" than when being resolved for use with "href",
which is explained in detail in the URI Templating section.
</t>
</section>
<section title="links">
<t>
The "links" property of schemas is used to associate Link Description Objects
with instances. The value of this property MUST be an array, and the items in
the array must be Link Description Objects, as defined below.
</t>
</section>
</section>
<section title="Link Description Object" anchor="ldo">
<t>
A Link Description Object (LDO) is a serialization of the abstract link model
defined in <xref target="RFC8288">RFC 8288, section 2</xref>.
As described in that document, a link consists of a context, a relation type,
a target, and optionally target attributes. JSON Hyper-Schema's LDO provides
all of these, along with additional features using JSON Schema to describe input
for use with the links in various ways.
</t>
<t>
Due to the use of URI Templates to identify link contexts and targets, as well
as optional further use of client input when identifying targets, an LDO is
a link template that may resolve to multiple links when used with a JSON
instance document.
</t>
<t>
A specific use of an LDO, typically involving a request and response across
a protocol, is referred to as an operation. For many protocols, multiple
operations are possible on any given link. The protocol is indicated by
the target's URI scheme. Note that not all URI schemes indicate a protocol
that can be used for communications, and even resources with URI schemes that
do indicate such protocols need not be available over that protocol.
</t>
<t>
A Link Description Object MUST be an object, and the
<xref target="href">"href"</xref> and <xref target="rel">"rel"</xref> properties
MUST be present. Each keyword is covered briefly in this section, with additional
usage explanation and comprehensive examples given later in the document.
</t>
<section title="Link Context" anchor="context">
<t>
In JSON Hyper-Schema, the link's context resource is, by default, the
sub-instance to which it is attached (as defined by
<xref target="json-schema-validation">Section 3 of the JSON Schema
validation specification</xref>). This is often not the entire instance
document. This default context can be changed using the keywords
in this section.
</t>
<t>
Depending on the media type of the instance, it may or may not be possible
to assign a URI to the exact default context resource. In particular,
application/json does not define a URI fragment resolution syntax, so
properties or array elements within a plain JSON document cannot be fully
identified by a URI. When it is not possible to produce a complete URI,
the position of the context SHOULD be conveyed by the URI of the instance
document, together with a separate plain-string JSON Pointer.
</t>
<t>
Implementations MUST be able to construct the link context's URI, and
(if necessary for full identification), a JSON Pointer in string representation
form as per <xref target="RFC6901">RFC 6901, section 5</xref> in place of
a URI fragment. The process for constructing a URI based on a URI template
is given in the <xref target="uriTemplating">URI Templating</xref> section.
</t>
<section title="anchor" anchor="anchor">
<t>
This property sets the context URI of the link.
The value of the property is a <xref target="RFC6570">URI Template</xref>,
and the resulting <xref target="RFC3986">URI-reference</xref> MUST
be resolved against the base URI of the instance.
</t>
<t>
The URI is computed from the provided URI template using the same process
described for the <xref target="href">"href"</xref> property, with the
exception that <xref target="hrefSchema">"hrefSchema"</xref> MUST NOT
be applied. Unlike target URIs, context URIs do not accept user input.
</t>
</section>
<section title="anchorPointer" anchor="anchorPointer">
<t>
This property changes the point within the instance that is considered
to be the context resource of the link. The value of the property MUST
be a valid JSON Pointer in JSON String representation form, or a valid
<xref target="relative-json-pointer">Relative JSON Pointer</xref>
which is evaluated relative to the default context.
</t>
<t>
While an alternate context with a known URI is best set with the
<xref target="anchor">"anchor"</xref> keyword, the lack of a fragment
identifier syntax for application/json means that it is usually not
possible to change the context within a JSON instance using a URI.
</t>
<t>
Even in "+json" media types that define JSON Pointer as a fragment
identifier syntax, if the default context is nested within an array,
it is not possible to obtain the index of the default context's position
in that array in order to construct a pointer to another property in that
same nested JSON object. This will be demonstrated in the examples.
</t>
<t>
The result of processing this keyword SHOULD be a URI fragment if the
media type of the instance allows for such a fragment. Otherwise it
MUST be a string-encoded JSON Pointer.
</t>
</section>
</section>
<section title="Link Relation Type" anchor="relationType">
<t>
The link's relation type identifies its semantics. It is the primary
means of conveying how an application can interact with a resource.
</t>
<t>
Relationship definitions are not normally media type
dependent, and users are encouraged to utilize the most
suitable existing accepted relation definitions.
</t>
<section title="rel" anchor="rel">
<t>
The value of this property MUST be a string, and MUST be a single
Link Relation Type as defined in RFC 8288, Section 2.1.
</t>
<t>
This property is required.
</t>
</section>
<section title='"self" Links' anchor="self">
<t>
A "self" link, as originally defined by <xref target="RFC4287">Section
4.2.7.2 of RFC 4287</xref>, indicates that the target URI identifies
a resource equivalent to the link context. In JSON Hyper-Schema,
a "self" link MUST be resolvable from the instance, and therefore
"hrefSchema" MUST NOT be present.
</t>
<t>
Hyper-schema authors SHOULD use "templateRequired" to ensure that the
"self" link has all instance data that is needed for use.
</t>
<t>
A hyper-schema implementation MUST recognize that a link with relation
type "self" that has the entire current instance document as its context
describes how a user agent can interact with the resource represented by
that instance document.
</t>
</section>
<section title='"collection" and "item" Links' anchor="collectionAndItem">
<t>
<xref target="RFC6573">RFC 6573</xref> defines and registers
the "item" and "collection" link relation types. JSON Hyper-Schema imposes
additional semantics on collection resources indicated by these types.
</t>
<t>
Implementations MUST recognize the target of a "collection" link and
the context of an "item" link as collections.
</t>
<t>
A well-known design pattern in hypermedia is to use a collection resource
to create a member of the collection and give it a server-assigned URI.
If the protocol indicated by the URI scheme defines a specific method
that is suited to creating a resource with a server-assigned URI, then
a collection resource, as identified by these link relation types,
MUST NOT define semantics for that method that conflict with the semantics
of creating a collection member. Collection resources MAY implement
item creation via such a protocol method, and user agents MAY assume
that any such operation, if it exists, has item creation semantics.
</t>
<t>
As such a method would correspond to JSON Hyper-Schema's data submission
concept, the <xref target="submissionSchema">"submissionSchema"</xref>
field for the link SHOULD be compatible with the schema of the
representation of the collection's items, as indicated by the "item" link's
target resource or the "self" link of the "collection" link's context
resource.
</t>
</section>
<section title="Using Extension Relation Types" anchor="extensionRelationTypes">
<t>
When no registered relation (aside from "related") applies, users are
encouraged to mint their own extension relation types, as described in
<xref target="RFC8288">section 2.1.2 of RFC 8288</xref>. The simplest
approaches for choosing link relation type URIs are to either use
a URI scheme that is already in use to identify the system's primary
resources, or to use a human-readable, non-dereferenceable URI scheme
such as <xref target="RFC4151">"tag", defined by RFC 4151</xref>.
</t>
<t>
Extension relation type URIs need not be dereferenceable, even when
using a scheme that allows it.
</t>
</section>
</section>
<section title="Link Target" anchor="target">
<t>
The target URI template is used to identify the link's target, potentially
making use of instance data. Additionally, with
<xref target="hrefSchema">"hrefSchema"</xref>, this template can identify
a set of possible target resources to use based on client input.
The full process of resolving the URI template, with or without client
input, is covered in the <xref target="uriTemplating">URI Templating</xref>
section.
</t>
<section title="href" anchor="href">
<t>
The value of the "href" link description property is a template used to
determine the target URI of the related resource.
The value of the instance property MUST be resolved as a
<xref target="RFC3986">URI-reference</xref> against the base URI of the
instance.
</t>
<t>
This property is REQUIRED.
</t>
</section>
</section>
<section title="Adjusting URI Template Resolution">
<t>
The keywords in this section are used when resolving all URI Templates
involved in hyper-schema: "base", "anchor", and "href". See the
<xref target="uriTemplating">URI Templating</xref> section for the complete
template resolution algorithm.
</t>
<t>
Note that when resolving a "base" template, the attachment point from
which resolution begins is the attachment point of the "href" or "anchor"
keyword being resolved which requires "base" templates to be resolved,
not the attachment point of the "base" keyword itself.
</t>
<section title="templatePointers" anchor="templatePointers">
<t>
The value of the "templatePointers" link description property MUST be
an object. Each property value in the object MUST be a valid
<xref target="RFC6901">JSON Pointer</xref>, or a valid
<xref target="relative-json-pointer">Relative JSON Pointer</xref>
which is evaluated relative to the attachment point of the link
for which the template is being resolved.
</t>
<t>
For each property name in the object that matches a variable name in the
template being resolved, the value of that property adjusts the starting
position of variable resolution for that variable. Properties which
do not match template variable names in the template being resolved
MUST be ignored.
</t>
</section>
<section title="templateRequired" anchor="templateRequired">
<t>
The value of this keyword MUST be an array, and the elements MUST be unique.
Each element SHOULD match a variable in the link's URI Template, without
percent-encoding. After completing the entire URI Template resolution
process, if any variable that is present in this array does not have
a value, the link MUST NOT be used.
</t>
</section>
</section>
<section title="Link Target Attributes" anchor="targetAttributes">
<t>
All properties in this section are advisory only. While keywords such
as "title" and "description" are used primarily to present the link
to users, those keywords that predict the nature of a link interaction
or response MUST NOT be considered authoritative. The runtime behavior
of the target resource MUST be respected whenever it conflicts with
the target attributes in the LDO.
</t>
<section title="title">
<t>
This property defines a title for the link.
The value MUST be a string.
</t>
<t>
User agents MAY use this title when presenting the link to the user.
</t>
</section>
<section title="description">
<t>
This property provides additional information beyond what
is present in the title. The value MUST be a string.
While a title is preferably short, a description can be
used to go into more detail about the purpose and usage
of the link.
</t>
<t>
User agents MAY use this description when presenting
the link to the user.
</t>
</section>
<section title="targetMediaType">
<t>
The value of this property represents the media type
<xref target="RFC2046">RFC 2046</xref>, that is expected to be returned
when fetching this resource. This property value MAY be a media range
instead, using the same pattern defined in
<xref target="RFC7231">RFC 7231, section 5.3.2 -
HTTP "Accept" header</xref>.
</t>
<t>
This property is analogous to the "type" property of other link
serialization formats. User agents MAY use this information to inform
the interface they present to the user before the link is followed,
but MUST NOT use this information in the interpretation of the resulting
data. Instead, a user agent MUST use the media type given by the response
for run-time interpretation. See the section on
<xref target="security">"Security Concerns"</xref> for a detailed
examination of mis-use of "targetMediaType".
</t>
<t>
For protocols supporting content-negotiation, implementations MAY choose to
describe possible target media types using protocol-specific information in
<xref target="headerSchema">"headerSchema"</xref>. If both
protocol-specific information and "targetMediaType" are present, then the
value of "targetMediaType" MUST be compatible with the protocol-specific
information, and SHOULD indicate the media type that will be returned in the
absence of content negotiation.
</t>
<t>
When no such protocol-specific information is available, or when the
implementation does not recognize the protocol involved, then the value
SHOULD be taken to be "application/json".
</t>
</section>
<section title="targetSchema" anchor="targetSchema">
<t>
This property provides a schema that is expected to describe
the link target's representation. Depending on the protocol,
the schema may or may not describe the request or response to
any particular operation performed with the link. See the
<xref target="HTTP">JSON Hyper-Schema and HTTP</xref> section for
an in-depth discussion of how this keyword is used with HTTP.
</t>
</section>
<section title="targetHints" anchor="targetHints">
<t>
<cref>
This section attempts to strike a balance between comprehensiveness
and flexibility by deferring most of its structure to the protocol
indicated by the URI scheme. Note that a resource can be identified
by a URI with a dereferenceable scheme, yet not be accessible over
that protocol. While currently very loose, this section is expected
to become more well-defined based on draft feedback, and may change
significantly in future drafts.
</cref>
</t>
<t>
The value of this property is advisory only. It represents information that
is expected to be discoverable through interacting with the target resource,
typically in the form of protocol-specific control information or meta-data
such as headers returned in response to an HTTP HEAD or OPTIONS request.
The protocol is determined by the "href" URI scheme, although note that
resources are not guaranteed to be accessible over such a protocol.
</t>
<t>
The value of this property SHOULD be an object. The keys to this object
SHOULD be lower-cased forms of the control data field names. Each value
SHOULD be an array, in order to uniformly handle multi-valued fields.
Multiple values MUST be presented as an array, and not as a single string.
</t>
<t>
Protocols with control information not suitable for representation as
a JSON object MAY be represented by another data type, such as an array.
</t>
<t>
Values that cannot be understood as part of the indicated protocol MUST
be ignored by a JSON Hyper-Schema implementation. Applications MAY make
use of such values, but MUST NOT assume interoperability with other
implementations.
</t>
<t>
Implementations MUST NOT assume that all discoverable information is
accounted for in this object. Client applications MUST properly handle
run-time responses that contradict this property's values.
</t>
<t>
Client applications MUST NOT assume that an implementation will
automatically take any action based on the value of this property.
</t>
<t>
See <xref target="HTTP">"JSON Hyper-Schema and HTTP"</xref> for
guidance on using this keyword with HTTP and analogous protocols.
</t>
</section>
</section>
<section title="Link Input" anchor="input">
<t>
There are four ways to use client input with a link, and each
is addressed by a separate link description object keyword. When performing
operations, user agents SHOULD ignore schemas that are not relevant to their
semantics.
</t>
<section title="hrefSchema" anchor="hrefSchema">
<t>
The value of the "hrefSchema" link description property MUST be
a valid JSON Schema. This schema is used to validate user input
or other user agent data for filling out the URI Template in
<xref target="href">"href"</xref>.
</t>
<t>
Omitting "hrefSchema" or setting the entire schema to "false" prevents
any user agent data from being accepted.
</t>
<t>
Setting any subschema that applies to a particular variable to the
JSON literal value "false" prevents any user agent data from being
accepted for that single variable.
</t>
<t>
For template variables that can be resolved from the instance data,
if the instance data is valid against all applicable subschemas
in "hrefSchema", then it MUST be used to pre-populate the input
data set for that variable.
</t>
<t>
Note that even when data is pre-populated from the instance, the
validation schema for that variable in "hrefSchema" need not be identical
to the validation schema(s) that apply to the instance data's location.
This allows for different validation rules for user agent data, such as
supporting spelled-out months for date-time input, but using the standard
date-time format for storage.
</t>
<t>
After input is accepted, potentially overriding the pre-populated
instance data, the resulting data set MUST successfully validate
against the value of "hrefSchema". If it does not then the link
MUST NOT be used. If it is valid, then the process given in the
"URI Templating" section continues with this updated data set.
</t>
</section>
<section title="headerSchema" anchor="headerSchema">
<t>
<cref>
As with "targetHints", this keyword is somewhat under-specified
to encourage experimentation and feedback as we try to balance
flexibility and clarity.
</cref>
</t>
<t>
If present, this property is a schema for protocol-specific request
headers or analogous control and meta-data. The value of this
object MUST be a valid JSON Schema.
The protocol is determined by the "href" URI scheme, although note that
resources are not guaranteed to be accessible over such a protocol.
The schema is advisory only; the target resource's behavior is not
constrained by its presence.
</t>
<t>
The purpose of this keyword is to advertise target resource interaction
features, and indicate to user agents and client applications what headers
and header values are likely to be useful.
User agents and client applications MAY use the schema to validate relevant
headers, but MUST NOT assume that missing headers or values are forbidden
from use. While schema authors MAY set "additionalProperties" to
false, this is NOT RECOMMENDED and MUST NOT prevent client applications
or user agents from supplying additional headers when requests are made.
</t>
<t>
The exact mapping of the JSON data model into the headers is
protocol-dependent. However, in most cases this schema SHOULD
specify a type of "object", and the property names SHOULD be
lower-cased forms of the control data field names. See the
<xref target="HTTP">"JSON Hyper-Schema and HTTP"</xref> section
for detailed guidance on using this keyword with HTTP and
analogous protocols.
</t>
<t>
"headerSchema" is applicable to any request method or command that the
protocol supports. When generating a request, user agents and client
applications SHOULD ignore schemas for headers that are not relevant
to that request.
</t>
</section>
<section title="Manipulating the Target Resource Representation">
<t>
In JSON Hyper-Schema, <xref target="targetSchema">"targetSchema"</xref>
supplies a non-authoritative description of the target resource's
representation. A client application can use "targetSchema" to structure
input for replacing or modifying the representation, or as the base
representation for building a patch document based on a patch media type.
</t>
<t>
Alternatively, if "targetSchema" is absent or if the client application
prefers to only use authoritative information, it can interact with the
target resource to confirm or discover its representation structure.
</t>
<t>
"targetSchema" is not intended to describe link operation responses,
except when the response semantics indicate that it is a representation
of the target resource. In all cases, the schema indicated by the response
itself is authoritative. See
<xref target="HTTP">"JSON Hyper-Schema and HTTP"</xref> for detailed
examples.
</t>
</section>
<section title="Submitting Data for Processing">
<t>
The <xref target="submissionSchema">"submissionSchema"</xref> and
<xref target="submissionMediaType">"submissionMediaType"</xref> keywords
describe the domain of the processing function implemented by the target
resource. Otherwise, as noted above, the submission schema and media type
are ignored for operations to which they are not relevant.
</t>
<section title="submissionMediaType" anchor="submissionMediaType">
<t>
If present, this property indicates the media type format the
client application and user agent should use for the request
payload described by
<xref target="submissionSchema">"submissionSchema"</xref>.
</t>
<t>
Omitting this keyword has the same behavior as a value of
application/json.
</t>
<t>
Note that "submissionMediaType" and "submissionSchema"
are not restricted to HTTP URIs.
<cref>This statement might move to wherever the example ends up.</cref>
</t>
</section>
<section title="submissionSchema" anchor="submissionSchema">
<t>
This property contains a schema which defines the acceptable structure
of the document to be encoded according to the "submissionMediaType"
property and sent to the target resource for processing. This can be
viewed as describing the domain of the processing function implemented
by the target resource.
</t>
<t>
This is a separate concept from the
<xref target="targetSchema">"targetSchema"</xref> property, which
describes the target information resource (including for replacing the
contents of the resource in a PUT request), unlike "submissionSchema"
which describes the user-submitted request data to be evaluated by the
resource. "submissionSchema" is intended for use with requests that
have payloads that are not necessarily defined in terms of the target
representation.
</t>
<t>
Omitting "submissionSchema" has the same behavior as a value of "true".
</t>
</section>
</section>
</section>
</section>
<section title="Implementation Requirements" anchor="implementation">
<t>
At a high level, a conforming implementation will meet the following
requirements. Each of these requirements is covered in more detail in the
individual keyword sections and keyword group overviews.
</t>
<t>
Note that the requirements around how an implementation MUST recognize
"self", "collection", and "item" links are thoroughly covered in the
<xref target="relationType">link relation type</xref> section and are not
repeated here.
</t>
<t>
While it is not a mandatory format for implementations, the output format used
in the test suite summarizes what needs to be computed for each link before
it can be used:
<list style="hanging">
<t hangText="contextUri">
The fully resolved URI (with scheme) of the context resource. If
the context is not the entire resource and there is a usable fragment
identifier syntax, then the URI includes a fragment. Note that there
is no such syntax for application/json.
</t>
<t hangText="contextPointer">
The JSON Pointer for the location within the instance of the context
resource. If the instance media type supports JSON Pointers as fragment
identifiers, this pointer will be the same as the one encoded in the
fragment of the "contextUri" field.
</t>
<t hangText="rel">
The link relation type, as it appears in the LDO.
</t>
<t hangText="targetUri">
The fully resolved URI (with a scheme) of the target resource. If the
link accepts input, this can only be produced once the input has been
supplied.
</t>
<t hangText="hrefInputTemplates">
The list of partially resolved URI references for a link that accepts
input. The first entry in the list is the partially resolved "href".
The additional entries, if any, are the partially resolved "base" values
ordered from the most immediate out to the root of the schema.
Template variables that are pre-populated in the input are not resolved
at this stage, as the pre-populated value can be overridden.
</t>
<t hangText="hrefPrepopulatedInput">
The data set that the user agent should use to prepopulate any
input mechanism before accepting client input. If input is to be
accepted but no fields are to be pre-populated, then this will be
an empty object.
</t>
<t hangText="attachmentPointer">
The JSON Pointer for the location within the instance to which the
link is attached. By default, "contextUri" and "attachmentPointer" are
the same, but "contextUri" can be changed by LDO keywords, while
"attachmentPointer" cannot.
</t>
</list>
Other LDO keywords that are not involved in producing the above information
are included exactly as they appear when producing output for the test suite.
Those fields will not be further discussed here unless specifically relevant.
</t>
<section title="Link Discovery and Look-Up">
<t>
Before links can be used, they must be discovered by applying the hyper-schema
to the instance and finding all applicable and valid links. Note that in
addition to collecting valid links, any <xref target="base">"base"</xref>
values necessary to resolve each LDO's URI Templates must also be located
and associated with the LDO through whatever mechanism is most useful for
the implementation's URI Template resolution process.
</t>
<t>
And implementation MUST support looking up links by either their
attachment pointer or context pointer, either by performing the look-up
or by providing the set of all links with both pointers determined
so that user agents can implement the look-up themselves.
</t>
<t>
When performing look-ups by context pointer, links that are attached to
elements of the same array MUST be returned in the same order as the
array elements to which they are attached.
</t>
</section>
<section title="URI Templating" anchor="uriTemplating">
<t>
Three hyper-schema keywords are <xref target="RFC6570">URI Templates</xref>:
"base", "anchor", and "href". Each are resolved separately to URI-references,
and then the anchor or href URI-reference is resolved against the base (which
is itself resolved against earlier bases as needed, each of which was first
resolved from a URI Template to a URI-reference).
</t>
<t>
All three keywords share the same algorithm for resolving variables from
instance data, which makes use of the "templatePointers" and "templateRequired"
keywords. When resolving "href", both it and any "base" templates
needed for resolution to an absolute URI, the algorithm is modified to
optionally accept user input based on the "hrefSchema" keyword.
</t>
<t>
For each URI Template (T), the following pseudocode describes an algorithm for
resolving T into a URI-reference (R). For the purpose of this algorithm:
<list style="symbols">
<t>
"ldo.templatePointers" is an empty object if the keyword was not
present and "ldo.templateRequired" is likewise an empty array.