jsonschema_schema/schema/vocabularies/content.rs
1use crate::SchemaValue;
2
3/// Content vocabulary — `contentMediaType`, `contentEncoding`,
4/// `contentSchema`.
5///
6/// See [JSON Schema Validation §8](https://json-schema.org/draft/2020-12/json-schema-validation#section-8).
7#[derive(
8 Debug,
9 Clone,
10 Default,
11 PartialEq,
12 Eq,
13 serde::Serialize,
14 serde::Deserialize,
15 schemars::JsonSchema,
16 combine_structs::Fields,
17)]
18pub struct ContentVocabulary {
19 /// The `contentMediaType` keyword — media type of string content.
20 ///
21 /// If the instance is a string, this property indicates the media
22 /// type of the contents of the string. If `"contentEncoding"` is
23 /// present, this property describes the decoded string.
24 ///
25 /// The value of this property MUST be a string, which MUST be a
26 /// media type, as defined by RFC 2046.
27 ///
28 /// See [JSON Schema Validation §8.4](https://json-schema.org/draft/2020-12/json-schema-validation#section-8.4).
29 #[serde(rename = "contentMediaType", skip_serializing_if = "Option::is_none")]
30 pub content_media_type: Option<String>,
31
32 /// The `contentEncoding` keyword — encoding of string content.
33 ///
34 /// If the instance value is a string, this property defines that
35 /// the string SHOULD be interpreted as encoded binary data and
36 /// decoded using the encoding named by this property.
37 ///
38 /// Possible values indicating base 16, 32, and 64 encodings with
39 /// several variations are listed in RFC 4648. Additionally,
40 /// sections 6.7 and 6.8 of RFC 2045 provide encodings used in
41 /// MIME.
42 ///
43 /// If this keyword is absent, but `"contentMediaType"` is present,
44 /// this indicates that the encoding is the identity encoding,
45 /// meaning that no transformation was needed in order to represent
46 /// the content in a UTF-8 string.
47 ///
48 /// The value of this property MUST be a string.
49 ///
50 /// See [JSON Schema Validation §8.3](https://json-schema.org/draft/2020-12/json-schema-validation#section-8.3).
51 #[serde(rename = "contentEncoding", skip_serializing_if = "Option::is_none")]
52 pub content_encoding: Option<String>,
53
54 /// The `contentSchema` keyword — schema for decoded string content.
55 ///
56 /// If the instance is a string, and if `"contentMediaType"` is
57 /// present, this property contains a schema which describes the
58 /// structure of the string.
59 ///
60 /// This keyword MAY be used with any media type that can be mapped
61 /// into JSON Schema's data model.
62 ///
63 /// The value of this property MUST be a valid JSON schema. It
64 /// SHOULD be ignored if `"contentMediaType"` is not present.
65 ///
66 /// See [JSON Schema Validation §8.5](https://json-schema.org/draft/2020-12/json-schema-validation#section-8.5).
67 #[serde(rename = "contentSchema", skip_serializing_if = "Option::is_none")]
68 pub content_schema: Option<Box<SchemaValue>>,
69}