pub enum FieldMetadata {
Default(Value),
Nullable,
Enumeration(Vec<String>),
}Expand description
Field metadata carried inside ValidationRule::Custom.
The contract’s rule list has no variant for a default, for nullability, or
for a string enumeration, and its encoding is frozen. #[api_model]
therefore writes them as keyword=value strings — the channel already used
for pattern and the numeric bounds — and a schema projection recovers them
with FieldMetadata::parse instead of treating them as opaque validator
names.
Variants§
Default(Value)
Value substituted when the field is absent from the request.
Nullable
The field accepts null in addition to its declared type.
Enumeration(Vec<String>)
The complete set of accepted string values, in declaration order.
Implementations§
Source§impl FieldMetadata
impl FieldMetadata
Sourcepub fn parse(encoded: &str) -> Option<Self>
pub fn parse(encoded: &str) -> Option<Self>
Parses the canonical keyword=value encoding emitted by #[api_model].
Sourcepub fn schema_value(&self) -> Value
pub fn schema_value(&self) -> Value
JSON Schema value this metadata projects to.
Sourcepub fn apply_json_schema(&self, schema: &mut Value)
pub fn apply_json_schema(&self, schema: &mut Value)
Writes the metadata into a JSON Schema object in place.
Trait Implementations§
Source§impl Clone for FieldMetadata
impl Clone for FieldMetadata
Source§fn clone(&self) -> FieldMetadata
fn clone(&self) -> FieldMetadata
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more