pub enum Schema {
Reference {
reference: String,
extra: BTreeMap<String, Value>,
},
RecursiveRef {
recursive_ref: String,
extra: BTreeMap<String, Value>,
},
DynamicRef {
dynamic_ref: String,
extra: BTreeMap<String, Value>,
},
OneOf {
one_of: Vec<Schema>,
discriminator: Option<Discriminator>,
details: SchemaDetails,
},
AnyOf {
schema_type: Option<SchemaType>,
any_of: Vec<Schema>,
discriminator: Option<Discriminator>,
details: SchemaDetails,
},
TypedMulti {
schema_types: Vec<SchemaType>,
details: SchemaDetails,
},
Typed {
schema_type: SchemaType,
details: SchemaDetails,
},
AllOf {
all_of: Vec<Schema>,
details: SchemaDetails,
},
Untyped {
details: SchemaDetails,
},
}Variants§
Reference
Schema reference
RecursiveRef
Recursive reference (older draft, kept for OAS 3.0 compatibility)
DynamicRef
Dynamic reference per JSON Schema 2020-12 (OAS 3.1+).
$dynamicRef resolves against the nearest enclosing $dynamicAnchor.
J1: modeled today; full dynamic resolution at analysis time is a
follow-up. Self-references via $dynamicRef: "#x" are treated as
recursive references to the schema bearing $dynamicAnchor: "x".
OneOf
OneOf union
AnyOf
AnyOf union (must come before Typed to handle type + anyOf patterns)
TypedMulti
Schema with type as an array (OpenAPI 3.1 / JSON Schema 2020-12).
The canonical 3.1 way to express a nullable type is
type: ["string", "null"]. Listed before Typed so the array form
matches first.
Typed
Schema with a single explicit type
AllOf
AllOf composition
Untyped
Schema without explicit type (inferred from other fields)
Fields
details: SchemaDetailsImplementations§
Source§impl Schema
impl Schema
Sourcepub fn schema_type(&self) -> Option<&SchemaType>
pub fn schema_type(&self) -> Option<&SchemaType>
Get the schema type if explicitly set. For Schema::TypedMulti the
“primary” non-null type is returned; if the array contained only null
then Some(&SchemaType::Null) is returned.
Sourcepub fn type_array_contains_null(&self) -> bool
pub fn type_array_contains_null(&self) -> bool
True when the schema’s type set explicitly contains null.
(3.1 canonical nullability via type: ["X", "null"].)
Sourcepub fn details(&self) -> &SchemaDetails
pub fn details(&self) -> &SchemaDetails
Get schema details
Sourcepub fn details_mut(&mut self) -> &mut SchemaDetails
pub fn details_mut(&mut self) -> &mut SchemaDetails
Get mutable schema details
Sourcepub fn is_reference(&self) -> bool
pub fn is_reference(&self) -> bool
Check if this is any kind of reference (regular or recursive)
Sourcepub fn recursive_reference(&self) -> Option<&str>
pub fn recursive_reference(&self) -> Option<&str>
Get recursive reference string if this is a recursive reference
Sourcepub fn is_discriminated_union(&self) -> bool
pub fn is_discriminated_union(&self) -> bool
Check if this is a discriminated union
Sourcepub fn discriminator(&self) -> Option<&Discriminator>
pub fn discriminator(&self) -> Option<&Discriminator>
Get discriminator if this is a discriminated union
Sourcepub fn union_variants(&self) -> Option<&[Schema]>
pub fn union_variants(&self) -> Option<&[Schema]>
Get union variants
Sourcepub fn is_nullable_pattern(&self) -> bool
pub fn is_nullable_pattern(&self) -> bool
Check if this appears to be a nullable pattern (anyOf or oneOf with null)
Sourcepub fn non_null_variant(&self) -> Option<&Schema>
pub fn non_null_variant(&self) -> Option<&Schema>
Get the non-null variant from a nullable pattern
Sourcepub fn inferred_type(&self) -> Option<SchemaType>
pub fn inferred_type(&self) -> Option<SchemaType>
Infer schema type from structure if not explicitly set