Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7401514

Browse files
Merge pull request #673 from handrews/content-schema
Add "contentSchema"
2 parents 0c5a6f2 + d91706a commit 7401514

File tree

1 file changed

+66
-10
lines changed

1 file changed

+66
-10
lines changed

‎jsonschema-validation.xml‎

Lines changed: 66 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@
726726
</section>
727727
</section>
728728

729-
<section title='String-Encoding Non-JSON Data' anchor="content">
729+
<section title='String-Encoded Data' anchor="content">
730730

731731
<section title="Foreword">
732732
<t>
@@ -773,6 +773,12 @@
773773
can be constrained using the <xref target="pattern">"pattern"</xref> keyword.
774774
</t>
775775

776+
<t>
777+
If this keyword is absent, but "contentMediaType" is present, this
778+
indicates that the media type could be encoded into UTF-8 like any
779+
other JSON string value, and does not require additional decoding.
780+
</t>
781+
776782
<t>
777783
The value of this property MUST be a string.
778784
</t>
@@ -786,25 +792,33 @@
786792

787793
<section title="contentMediaType">
788794
<t>
789-
The value of this property must be a media type, as defined by
790-
<xreftarget="RFC2046">RFC 2046</xref>. This property defines the media
791-
type of instances which this schema defines.
795+
If the instance is a string, this property defines the media type
796+
of the contents of the string. If "contentEncoding" is present,
797+
this property describes the decoded string.
792798
</t>
793-
794799
<t>
795-
The value of this property MUST be a string.
800+
The value of this property MUST be a string, which MUST be a media type,
801+
as defined by <xref target="RFC2046">RFC 2046</xref>.
796802
</t>
797803

798804
<t>
799805
The value of this property SHOULD be ignored if the instance described is not a
800806
string.
801807
</t>
808+
</section>
802809

810+
<section title="contentSchema">
803811
<t>
804-
If the "contentEncoding" property is not present, but the instance value is a
805-
string, then the value of this property SHOULD specify a text document type,
806-
and the character set SHOULD be the character set into which the JSON string
807-
value was decoded (for which the default is Unicode).
812+
If the instance is a string, and if "contentMediaType" is present, this
813+
property contains a schema which describes the structure of the string.
814+
</t>
815+
<t>
816+
This keyword MAY be used with any media type that can be mapped into
817+
JSON Schema's data model.
818+
</t>
819+
<t>
820+
The value of this property SHOULD be ignored if the instance described is not a
821+
string, or if "contentMediaType" is not present.
808822
</t>
809823
</section>
810824

@@ -847,6 +861,48 @@
847861
Unicode).
848862
</postamble>
849863
</figure>
864+
865+
<figure>
866+
<preamble>
867+
This example describes a JWT that is MACed using the HMAC SHA-256
868+
algorithm, and requires the "iss" and "exp" fields in its claim set.
869+
</preamble>
870+
<artwork>
871+
<![CDATA[
872+
{
873+
"type": "string",
874+
"contentMediaType": "application/jwt",
875+
"contentSchema": {
876+
"type": "array",
877+
"minItems": 2,
878+
"items": [
879+
{
880+
"const": {
881+
"typ": "JWT",
882+
"alg": "HS256"
883+
}
884+
},
885+
{
886+
"type": "object",
887+
"required": ["iss", "exp"],
888+
"properties": {
889+
"iss": {"type": "string"},
890+
"exp": {"type": "integer"}
891+
}
892+
}
893+
]
894+
}
895+
}]]>
896+
</artwork>
897+
<postamble>
898+
Note that "contentEncoding" does not appear. While the "application/jwt"
899+
media type makes use of base64url encoding, that is defined by the media
900+
type, which determines how the JWT string is decoded into a list of two
901+
JSON data structures: first the header, and then the payload. Since the
902+
JWT media type ensures that the JWT can be represented in a JSON string,
903+
there is no need for further encoding or decoding.
904+
</postamble>
905+
</figure>
850906
</section>
851907

852908
</section>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /