Skip to content

Commit 62997d1

Browse files
committed
Add a section on links and data.
1 parent 3f9ca46 commit 62997d1

File tree

1 file changed

+47
-15
lines changed

1 file changed

+47
-15
lines changed

jsonschema-hyperschema.xml

Lines changed: 47 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -366,9 +366,32 @@
366366
The URI of the normative link description schema is: <eref target="http://json-schema.org/draft-04/links">http://json-schema.org/draft-04/links</eref> (draft-04 version).
367367
</t>
368368

369-
<t>
370-
"Form"-like functionality can be defined by use of the "method" and "schema" keywords, which supplies a schema describing the data to supply to the server.
371-
</t>
369+
<section title="Links and data">
370+
<t>
371+
"Form"-like functionality can be defined by use of the "method" and "schema" keywords, which supplies a schema describing the data to supply to the server.
372+
Functionality equivalent to dynamic URI generation is available through the "href" template and "hrefSchema".
373+
</t>
374+
<t>
375+
The simplest kind of link has an "href" with no template variables, and no "schema". This does not
376+
allow for any variance in the link URI, nor does it allow for a request document.
377+
</t>
378+
<t>
379+
An "href" with at least one template variable, but no "hrefSchema" or "schema, allows resolving
380+
the variable from the instance, but does not allow for the use of any external data.
381+
</t>
382+
<t>
383+
An "href" with at least one template variable and with an "hrefSchema" allows using external
384+
data to resolve the template, and falls back to resolving any remaining variables from the instance.
385+
</t>
386+
<t>
387+
A link with a "schema" allows submitting external data either as a request body (if "method" is "post"),
388+
or as a URI query string (if "method" is "get"). Such a query string replaces any query string
389+
from the resolved template in "href".
390+
</t>
391+
<t>
392+
See the individual keyword descriptions below for details related to each of these cases.
393+
</t>
394+
</section>
372395

373396
<!-- Possibly include a short section on motivations, including triples, resources, and progressive disclosure -->
374397

@@ -473,27 +496,30 @@
473496

474497
<section title="Values for substitution">
475498
<t>
476-
After pre-processing, the URI Template is filled out using data from some combination of user input and the instance.
499+
After pre-processing, the URI Template is filled out using data from some combination of an externa source and the instance.
500+
Where either instance data or external data may be used, this section will refer simply to "data" or to a "value".
501+
When the source is important, it is specified explicitly.
477502

478503
To allow the use of any object property (including the empty string), array index, or the instance value itself, the following rules are defined:
479504
</t>
480505

481506
<t>
482507
For a given variable name in the URI Template, the value to use is determined as follows:
483508
<list>
484-
<t>If the variable name is "%73elf", then the instance value itself MUST be used.</t>
485-
<t>If the variable name is "%65mpty", then the instances's empty-string ("") property MUST be used (if it exists).</t>
486-
<t>If the instance is an array, and the variable name is a representation of a non-negative integer, then the value at the corresponding array index MUST be used (if it exists).</t>
509+
<t>If the variable name is "%73elf", then the value itself MUST be used.</t>
510+
<t>If the variable name is "%65mpty", then the empty-string ("") property MUST be used (if it exists).</t>
511+
<t>If the data is an array, and the variable name is a representation of a non-negative integer, then the value at the corresponding array index MUST be used (if it exists).</t>
487512
<t>Otherwise, the variable name should be percent-decoded, and the corresponding object property MUST be used (if it exists).</t>
488513
</list>
489514
</t>
490515

491516
<t>
492517
If <xref target="hrefSchema">"hrefSchema"</xref> is present and
493-
user input is provided, the input MUST be valid according to the value of "hrefSchema".
518+
external input is provided, the input MUST be a valid instance according
519+
to the value of "hrefSchema".
494520
Template variables, after the process listed above, MUST first
495-
be resolved from the user input instance. Any variables left
496-
unresolved MUST be resolved from the resource instance.
521+
be resolved from the external data instance. Any variables left
522+
unresolved MUST be resolved from the resource instance data.
497523
</t>
498524

499525
<section title="Converting to strings">
@@ -531,16 +557,16 @@
531557
<t>
532558
The value of the "hrefSchema" link description property MUST be
533559
a valid JSON Schema. This schema is used to validate user input
534-
for filling out the URI Template in
560+
or other external data for filling out the URI Template in
535561
<xref target="href">"href"</xref>, as described in that section.
536562
</t>
537563
<t>
538564
Omitting "hrefSchema" or setting the entire schema to "false" prevents
539-
any user input from being accepted.
565+
any external data from being accepted.
540566
</t>
541567
<t>
542568
Implementations MUST NOT attempt to validate values resolved from
543-
instance data with "hrefSchema". This allows for different
569+
resource instance data with "hrefSchema". This allows for different
544570
validation rules for user input, such as supporting spelled-out
545571
months for date-time input but using the standard date-time
546572
format for storage.
@@ -575,9 +601,9 @@
575601
<figure>
576602
<preamble>
577603
In this example, the schema for "extra" is given as a reference
578-
to keep the user input validation constraints identical to the
604+
to keep the external data validation constraints identical to the
579605
instance validation constraints for the corresponding property,
580-
while "id" is given a false schema to prevent user input for
606+
while "id" is given a false schema to prevent external data for
581607
that variable.
582608
</preamble>
583609
<artwork>
@@ -610,6 +636,12 @@
610636
}]]>
611637
</artwork>
612638
</figure>
639+
<t>
640+
<cref>
641+
The above example simulates the behavior found in earlier drafts using only "hrefSchema",
642+
which would allow the concurrent use of "schema" on a "post" link.
643+
</cref>
644+
</t>
613645
</section>
614646

615647
<section title="rel">

0 commit comments

Comments
 (0)