You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/2020-12/content/contentMediaType.markdown
+52-4Lines changed: 52 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,11 +21,59 @@ related:
21
21
keyword: contentEncoding
22
22
---
23
23
24
-
The `contentMediaType` keyword in JSON Schema specifies the MIME type of the contents of a string. It is used to annotate the type of media contained within a string. It should be noted that:
24
+
When the [`contentEncoding`]({{< ref "2020-12/content/contentencoding" >}})
25
+
keyword is set, the `contentMediaType` keyword signifies that a string instance
26
+
value (such as a specific object property) should be considered binary data
27
+
that represents the given type. This keyword does not affect validation, but
28
+
the evaluator will collect its value as an annotation. The use of this and
29
+
related keywords is a common technique to encode and describe arbitrary binary
30
+
data (such as image, audio, and video) in JSON.
25
31
26
-
* This keyword is purely an annotation and does not directly affect validation.
27
-
* It describes the media type of the binary string after it has been decoded as specified in `contentEncoding`.
28
-
* It is recommended to set `contentEncoding` if `contentMediaType` is declared.
32
+
{{<best-practice>}}
33
+
34
+
It is recommended to set this keyword along with the [`contentEncoding`]({{<
35
+
ref "2020-12/content/contentencoding" >}}) keyword to declare the encoding used
36
+
to serialised the data (for example, Base 64 encoding). Otherwise, the
37
+
receiver must treat the instance value as a binary blob without knowing for
38
+
sure how to decode it.
39
+
40
+
{{</best-practice>}}
41
+
42
+
{{<common-pitfall>}}
43
+
44
+
The JSON Schema specification prohibits implementations, for security reasons,
45
+
from automatically attempting to decode, parse, or validate encoded data
46
+
without the consumer explicitly opting in to such behaviour. If you require
47
+
this feature, consult the documentation of your tooling of choice to see if it
48
+
supports content encoding/decoding and how to enable it.
0 commit comments