Skip to content

Commit 29b7b46

Browse files
dlaxDenis Laxalde
authored and
Denis Laxalde
committed
Move media from Hyper-Schema as contentMediaType/contentEncoding in Validation
Definition of "media" property (an object in Hyper-Schema) is moved into two properties "contentMediaType" and "contentEncoding" in the validation specification. This addresses the other part of json-schema-org#363, which states that some keywords historically in the Hyper-Schema specification would be better in the Validation document. The main argument for moving keywords such as "media" is that the Hyper-Schema document could then only focus on describing the hypermedia linking model. The new keywords are described in a dedicated section "String-encoding non-JSON data". Part of the previous content was moved into a forewords section.
1 parent 1ae197a commit 29b7b46

File tree

2 files changed

+103
-93
lines changed

2 files changed

+103
-93
lines changed

jsonschema-hyperschema.xml

Lines changed: 1 addition & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?xml version="1.0" encoding="US-ASCII"?>
22
<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
3-
<!ENTITY rfc2045 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2045.xml">
43
<!ENTITY rfc2046 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2046.xml">
54
<!ENTITY rfc2119 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml">
65
<!ENTITY rfc3986 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.3986.xml">
@@ -337,94 +336,6 @@
337336
</figure>
338337
</section>
339338

340-
<section title="media">
341-
<t>
342-
The "media" property indicates that this instance contains non-JSON data encoded
343-
in a JSON string.
344-
It describes the type of content and how it is encoded.
345-
</t>
346-
<t>
347-
The value of this property MUST be an object.
348-
The value of this property SHOULD be ignored if the instance described is not a
349-
string.
350-
</t>
351-
352-
<section title="Properties of &quot;media&quot;">
353-
<t>
354-
The value of the "media" keyword MAY contain any of the following
355-
properties:
356-
</t>
357-
358-
<section title="binaryEncoding">
359-
<t>
360-
If the instance value is a string, this property defines that the string
361-
SHOULD be interpreted as binary data and decoded using the encoding
362-
named by this property.
363-
<xref target="RFC2045">RFC 2045, Sec 6.1</xref> lists the possible
364-
values for this property.
365-
</t>
366-
</section>
367-
368-
<section title="type">
369-
<t>
370-
The value of this property must be a media type, as defined by
371-
<xref target="RFC2046">RFC 2046</xref>. This property defines the media
372-
type of instances which this schema defines.
373-
</t>
374-
375-
<t>
376-
If the "binaryEncoding" property is not set, but the instance value is a
377-
string, then the value of this property SHOULD specify a text document
378-
type, and the character set SHOULD be the character set into which the
379-
JSON string value was decoded (for which the default is Unicode).
380-
</t>
381-
</section>
382-
</section>
383-
384-
<section title="Example">
385-
<figure>
386-
<preamble>
387-
Here is an example schema, illustrating the use of "media":
388-
</preamble>
389-
<artwork>
390-
<![CDATA[
391-
{
392-
"type": "string",
393-
"media": {
394-
"binaryEncoding": "base64",
395-
"type": "image/png"
396-
}
397-
}
398-
]]>
399-
</artwork>
400-
<postamble>
401-
Instances described by this schema should be strings, and their values
402-
should be interpretable as base64-encoded PNG images.
403-
</postamble>
404-
</figure>
405-
406-
<figure>
407-
<preamble>
408-
Another example:
409-
</preamble>
410-
<artwork>
411-
<![CDATA[
412-
{
413-
"type": "string",
414-
"media": {
415-
"type": "text/html"
416-
}
417-
}
418-
]]>
419-
</artwork>
420-
<postamble>
421-
Instances described by this schema should be strings containing HTML,
422-
using whatever character set the JSON string was decoded into (default
423-
is Unicode).
424-
</postamble>
425-
</figure>
426-
</section>
427-
</section>
428339
</section>
429340

430341
<section title="Link Description Object">
@@ -1009,9 +920,7 @@ GET /foo/
1009920
"properties": {
1010921
"message": {
1011922
"description": "Re-interpret `message` as HTML",
1012-
"media": {
1013-
"type": "text/html"
1014-
}
923+
"contentMediaType": "text/html"
1015924
}
1016925
}
1017926
}
@@ -1230,7 +1139,6 @@ GET /foo/
12301139
<back>
12311140
<!-- References Section -->
12321141
<references title="Normative References">
1233-
&rfc2045;
12341142
&rfc2119;
12351143
&rfc3986;
12361144
<!--&rfc4287;-->

jsonschema-validation.xml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<?xml version="1.0" encoding="US-ASCII"?>
22
<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
33
<!ENTITY RFC1034 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.1034.xml">
4+
<!ENTITY RFC2045 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2045.xml">
5+
<!ENTITY RFC2046 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2046.xml">
46
<!ENTITY RFC2119 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml">
57
<!ENTITY RFC2673 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2673.xml">
68
<!ENTITY RFC3339 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.3339.xml">
@@ -993,6 +995,104 @@
993995
</section>
994996
</section>
995997

998+
<section title='String-encoding non-JSON data'>
999+
1000+
<section title="Foreword">
1001+
<t>
1002+
Properties defined in this section indicate that an instance contains
1003+
non-JSON data encoded in a JSON string.
1004+
They describe the type of content and how it is encoded.
1005+
</t>
1006+
</section>
1007+
1008+
<section title="contentEncoding">
1009+
1010+
<t>
1011+
If the instance value is a string, this property defines that the string
1012+
SHOULD be interpreted as binary data and decoded using the encoding
1013+
named by this property.
1014+
<xref target="RFC2045">RFC 2045, Sec 6.1</xref> lists the possible
1015+
values for this property.
1016+
</t>
1017+
1018+
<t>
1019+
The value of this property MUST be a string.
1020+
</t>
1021+
1022+
<t>
1023+
The value of this property SHOULD be ignored if the instance described is not a
1024+
string.
1025+
</t>
1026+
1027+
</section>
1028+
1029+
<section title="contentMediaType">
1030+
<t>
1031+
The value of this property must be a media type, as defined by
1032+
<xref target="RFC2046">RFC 2046</xref>. This property defines the media
1033+
type of instances which this schema defines.
1034+
</t>
1035+
1036+
<t>
1037+
The value of this property MUST be a string.
1038+
</t>
1039+
1040+
<t>
1041+
The value of this property SHOULD be ignored if the instance described is not a
1042+
string.
1043+
</t>
1044+
1045+
<t>
1046+
If the "contentEncoding" property is not present, but the instance value is a
1047+
string, then the value of this property SHOULD specify a text document type,
1048+
and the character set SHOULD be the character set into which the JSON string
1049+
value was decoded (for which the default is Unicode).
1050+
</t>
1051+
</section>
1052+
1053+
<section title="Example">
1054+
<figure>
1055+
<preamble>
1056+
Here is an example schema, illustrating the use of "contentEncoding" and
1057+
"contentMediaType":
1058+
</preamble>
1059+
<artwork>
1060+
<![CDATA[
1061+
{
1062+
"type": "string",
1063+
"contentEncoding": "base64",
1064+
"contentMediaType": "image/png"
1065+
}
1066+
]]>
1067+
</artwork>
1068+
<postamble>
1069+
Instances described by this schema should be strings, and their values
1070+
should be interpretable as base64-encoded PNG images.
1071+
</postamble>
1072+
</figure>
1073+
1074+
<figure>
1075+
<preamble>
1076+
Another example:
1077+
</preamble>
1078+
<artwork>
1079+
<![CDATA[
1080+
{
1081+
"type": "string",
1082+
"contentMediaType": "text/html"
1083+
}
1084+
]]>
1085+
</artwork>
1086+
<postamble>
1087+
Instances described by this schema should be strings containing HTML, using
1088+
whatever character set the JSON string was decoded into (default is
1089+
Unicode).
1090+
</postamble>
1091+
</figure>
1092+
</section>
1093+
1094+
</section>
1095+
9961096
<section title="Security considerations">
9971097
<t>
9981098
JSON Schema validation defines a vocabulary for JSON Schema core and concerns all
@@ -1034,6 +1134,8 @@
10341134

10351135
<references title="Informative References">
10361136
&RFC1034;
1137+
&RFC2045;
1138+
&RFC2046;
10371139
&RFC2673;
10381140
&RFC3339;
10391141
&RFC3986;

0 commit comments

Comments
 (0)