@@ -105,8 +105,8 @@ define their own dialects of JSON Schema.
105
105
106
106
### JSON Document
107
107
108
- A JSON document is an information resource (series of octets) described by the
109
- ` application/json ` media type .
108
+ In JSON Schema, the terms "JSON document", "JSON data", and "JSON value" are
109
+ interchangeable and refer to the data model defined in {{data-model}} .
110
110
111
111
In JSON Schema, the terms "JSON document", "JSON text", and "JSON value" are
112
112
interchangeable because of the data model it defines in {{data-model}}.
@@ -117,13 +117,8 @@ model can be interpreted against a JSON Schema.
117
117
118
118
### Instance
119
119
120
- A JSON document to which a schema is applied is known as an "instance".
121
-
122
- JSON Schema is defined over ` application/json ` or compatible documents,
123
- including media types with the ` +json ` structured syntax suffix.
124
-
125
- Among these, this specification defines the ` application/schema-instance+json `
126
- media type which defines handling for fragments in the IRI.
120
+ A JSON document to which a schema is applied is known as a "JSON instance" or
121
+ just an "instance".
127
122
128
123
#### Instance Data Model {#data-model}
129
124
@@ -193,12 +188,8 @@ use of the `const` keyword.
193
188
194
189
### JSON Schema Documents {#schema-document}
195
190
196
- A JSON Schema document, or simply a schema, is a JSON document used to describe
197
- an instance. A schema can itself be interpreted as an instance, but SHOULD
198
- always be given the media type ` application/schema+json ` rather than
199
- ` application/schema-instance+json ` . The ` application/schema+json ` media type is
200
- defined to offer a superset of the fragment identifier syntax and semantics
201
- provided by ` application/schema-instance+json ` .
191
+ A JSON Schema document, or simply a schema, is used to describe an instance. A
192
+ schema can itself be interpreted as an instance.
202
193
203
194
A JSON Schema MUST be an object or a boolean.
204
195
@@ -909,21 +900,25 @@ steps.
909
900
910
901
1 . The ` $schema ` keyword - Implementations MUST process the schema according to
911
902
the dialect it declares.
912
- 2 . ` application/schema+json ` media type with a ` schema ` parameter -
913
- Implementations which support media type parameter inputs MUST process the
914
- schema according to the dialect the parameter declares. A media type will
915
- generally only be available if the schema has been retrieved from an external
916
- source and only applies to the document root.
917
- 3 . Parent dialect - An embedded schema resource which does not itself contain a
918
- ` $schema ` keyword MUST be processed using the same dialect as the schema
919
- which contains it. If the schema is embedded in a non-schema document, the
920
- semantics for determining the dialect MAY be determined by any specification
921
- which applies to that document.
903
+ 2 . Parent schema dialect - A schema resource embedded within another schema
904
+ resource which does not itself contain a ` $schema ` keyword MUST be processed
905
+ using the same dialect as the schema which contains it.
906
+ 3 . External context - In some contexts, there is a default dialect or a way to
907
+ declare the dialect external from the schema resource in question. Examples
908
+ include the following.
909
+ - If the schema is embedded in a non-schema document (such as an OpenAPI
910
+ Document), the semantics for determining the dialect MUST be determined by
911
+ the specification that applies to that document.
912
+ - If the media type of the schema is known and the media type defines a
913
+ default dialect or a way to declare a dialect, the dialect MUST be
914
+ determined by the rules of that media types. For example, the
915
+ [ application/schema+json] media type includes a ` schema ` parameter that
916
+ can be used to declare the dialect. A media type will generally only be
917
+ available if the schema has been retrieved from an external source and
918
+ only applies to the document root.
922
919
4 . User configuration - Implementations MAY provide means for the user to
923
920
configure the dialect under which a schema should be processed.
924
921
925
- (Note that steps 2 and 3 are mutually exclusive.)
926
-
927
922
If the dialect is not specified through one of these methods, the implementation
928
923
MUST refuse to process the schema.
929
924
@@ -940,9 +935,6 @@ The value of this keyword MUST be an
940
935
[ IRI] ( https://www.rfc-editor.org/info/rfc3987 ) (containing a scheme) and this
941
936
IRI MUST be normalized.
942
937
943
- If this IRI identifies a retrievable resource, that resource SHOULD be of media
944
- type ` application/schema+json ` .
945
-
946
938
The ` $schema ` keyword SHOULD be used in the document root schema object, and MAY
947
939
be used in the root schema objects of embedded schema resources. This keyword
948
940
MUST NOT appear in a subschema that is not also the root object of a schema
@@ -1143,11 +1135,10 @@ this string to end users. Tools for editing schemas SHOULD support displaying
1143
1135
and editing this keyword. The value of this keyword MAY be used in debug or
1144
1136
error output which is intended for developers making use of schemas.
1145
1137
1146
- Tools that translate other media types or programming languages to and from
1147
- ` application/schema+json ` MAY choose to convert that media type or programming
1148
- language's native comments to or from ` $comment ` values. The behavior of such
1149
- translation when both native comments and ` $comment ` properties are present is
1150
- implementation-dependent.
1138
+ Tools that translate schemas between media types or programming languages MAY
1139
+ choose to convert that media type or programming language's native comments to
1140
+ or from ` $comment ` values. The behavior of such translation when both native
1141
+ comments and ` $comment ` properties are present is implementation-dependent.
1151
1142
1152
1143
Implementations MAY strip ` $comment ` values at any point during processing. In
1153
1144
particular, this allows for shortening schemas when the size of deployed schemas
@@ -1181,8 +1172,8 @@ implementation-specific default IRI MAY be used as described in RFC 3987 Section
1181
1172
6.5 and RFC 3986 Section 5.1.4. It is RECOMMENDED that implementations document
1182
1173
any default base IRI that they assume.
1183
1174
1184
- If a schema object is embedded in a document of another media type , then the
1185
- initial base IRI is determined according to the rules of that media type .
1175
+ If a schema object is embedded in a document that is not a schema , then the
1176
+ initial base IRI is determined according to the rules of that document .
1186
1177
1187
1178
Unless the ` $id ` keyword described in an earlier section is present in the root
1188
1179
schema, this base IRI SHOULD be considered the canonical IRI of the schema
@@ -1460,14 +1451,17 @@ custom keywords.
1460
1451
A reference target under a keyword for which the value is not explicitly known
1461
1452
to be a schema results in undefined behavior. Implementations MAY support
1462
1453
references to these locations, however such behavior is not considered
1463
- interoperable and should not be relied upon.[ ^ 10 ]
1454
+ interoperable and should not be relied upon.
1464
1455
1465
- [ ^ 10 ] : These scenarios are analogous to fetching a schema over HTTP but
1466
- receiving a response with a Content-Type other than ` application/schema+json ` .
1467
- An implementation can certainly try to interpret it as a schema, but the origin
1468
- server offered no guarantee that it actually is any such thing. Therefore,
1469
- interpreting it as such has security implication and may produce unpredictable
1470
- results.
1456
+ When a schema is resolved over HTTP or another protocol that declares the media
1457
+ type of the response, implementations SHOULD refuse to evaluate schemas whose
1458
+ declared media type is not a known and supported JSON Schema media type such as
1459
+ [ application/schema+json] .[ ^ 10 ]
1460
+
1461
+ [ ^ 10 ] : An implementation can certainly try to interpret it as a schema, but
1462
+ there's no guarantee that it can be parsed and evaluated as a schema. Therefore,
1463
+ interpreting it as such has security implications and may produce unpredictable
1464
+ or malicious results.
1471
1465
1472
1466
#### Failure to resolve references {#failed-refs}
1473
1467
@@ -2159,49 +2153,6 @@ Third-party JSON Schema extensions may introduce additional risks. Implementers
2159
2153
are advised to consult the specifications of any extensions they support and
2160
2154
take into account their security considerations as well.
2161
2155
2162
- ## IANA Considerations
2163
-
2164
- ### ` application/schema+json `
2165
-
2166
- The proposed MIME media type for JSON Schema is defined as follows:
2167
-
2168
- Type name:: application
2169
-
2170
- Subtype name:: schema+json
2171
-
2172
- Required parameters:: N/A
2173
-
2174
- Encoding considerations:: Encoding considerations are identical to those
2175
- specified for the ` application/json ` media type. See [ JSON] [ rfc8259 ] .
2176
-
2177
- Security considerations:: See {{security}} above.
2178
-
2179
- Interoperability considerations:: See Sections [ 6.2] ( #language ) ,
2180
- [ 6.3] ( #data-model ) , and [ 6.4] ( #regex ) above.
2181
-
2182
- Fragment identifier considerations:: See {{fragments}}
2183
-
2184
- ### ` application/schema-instance+json `
2185
-
2186
- The proposed MIME media type for JSON Schema Instances that require a JSON
2187
- Schema-specific media type is defined as follows:
2188
-
2189
- Type name:: application
2190
-
2191
- Subtype name:: schema-instance+json
2192
-
2193
- Required parameters:: N/A
2194
-
2195
- Encoding considerations:: Encoding considerations are identical to those
2196
- specified for the ` application/json ` media type. See [ JSON] [ rfc8259 ] .
2197
-
2198
- Security considerations:: See {{security}} above.
2199
-
2200
- Interoperability considerations:: See Sections [ 6.2] ( #language ) ,
2201
- [ 6.3] ( #data-model ) , and [ 6.4] ( #regex ) above.
2202
-
2203
- Fragment identifier considerations:: See {{fragments}}
2204
-
2205
2156
## %appendix% Schema identification examples {#idexamples}
2206
2157
2207
2158
Consider the following schema, which shows ` $id ` being used to identify both the
@@ -2676,3 +2627,4 @@ to the document.
2676
2627
[ rfc6901 ] : https://www.rfc-editor.org/info/rfc6901
2677
2628
[ rfc8259 ] : https://www.rfc-editor.org/info/rfc8259
2678
2629
[ rfc8288 ] : https://www.rfc-editor.org/info/rfc8288
2630
+ [ application/schema+json ] : ../ietf/json-schema-media-types.md
0 commit comments