pub enum ObjectAdditionalProperties {
Denied,
Closed,
Untyped,
Typed {
value_type: Box<SchemaType>,
},
}Expand description
How an Object handles additionalProperties. Q2.3 split the
pre-existing bool into a three-way enum so the generator can
emit a typed BTreeMap<String, T> when the spec provides a
value-type schema instead of degrading to serde_json::Value.
Variants§
Denied
additionalProperties: false: the document itself forbids extra keys.
No catch-all field is emitted, and because the rule is stated rather
than assumed the generated struct may also reject extra keys — which
it must, to stay distinguishable as an untagged union branch.
Closed
The keyword is omitted. JSON Schema leaves such an object open; the
generator projects it closed (no catch-all field) while no required
unknown member forces an open carrier. Unlike Self::Denied this is
the generator’s projection, not a rule the document stated, so the
struct stays tolerant of keys it does not declare.
Untyped
additionalProperties: true — extra keys captured as
BTreeMap<String, serde_json::Value>.
Typed
additionalProperties: <schema> — extra keys captured as
BTreeMap<String, T> where T comes from the schema.
Fields
value_type: Box<SchemaType>Implementations§
Source§impl ObjectAdditionalProperties
impl ObjectAdditionalProperties
Sourcepub fn is_open(&self) -> bool
pub fn is_open(&self) -> bool
True when extra keys are accepted (regardless of typing). Used by callers that only care whether the field exists.
Sourcepub fn denies_unknown_keys(&self) -> bool
pub fn denies_unknown_keys(&self) -> bool
True when the document forbids extra keys, as opposed to the generator merely projecting a closed struct. Only this case may tighten the generated struct’s own deserialization.
Trait Implementations§
Source§impl Clone for ObjectAdditionalProperties
impl Clone for ObjectAdditionalProperties
Source§fn clone(&self) -> ObjectAdditionalProperties
fn clone(&self) -> ObjectAdditionalProperties
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more