#[non_exhaustive]pub struct Discriminator {
pub property_name: String,
pub mapping: PropMap<String, String>,
pub default_mapping: Option<String>,
pub extensions: PropMap<String, Value>,
}Expand description
OpenAPI Discriminator object which can be optionally used together with
OneOf composite object.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.property_name: StringDefines a discriminator property name which must be found within all composite objects.
mapping: PropMap<String, String>An object to hold mappings between payload values and schema names or references. This field can only be populated manually. There is no macro support and no validation.
default_mapping: Option<String>The schema name or URI reference to the schema that validates the payload when the discriminating property is absent, or holds a value with no explicit or implicit mapping. Added in OpenAPI 3.2.
Required by the spec when the discriminating property is optional.
See https://spec.openapis.org/oas/v3.2.0.html#discriminator-object.
extensions: PropMap<String, Value>Optional extensions “x-something”
Implementations§
Source§impl Discriminator
impl Discriminator
Sourcepub fn new<I: Into<String>>(property_name: I) -> Self
pub fn new<I: Into<String>>(property_name: I) -> Self
Construct a new Discriminator object with property name.
§Examples
Create a new Discriminator object for pet_type property.
let discriminator = Discriminator::new("pet_type");Sourcepub fn add_mapping<K: Into<String>, V: Into<String>>(
self,
value: K,
schema: V,
) -> Self
pub fn add_mapping<K: Into<String>, V: Into<String>>( self, value: K, schema: V, ) -> Self
Add a mapping between a payload value and a schema name or URI reference.
Sourcepub fn default_mapping<I: Into<String>>(self, default_mapping: I) -> Self
pub fn default_mapping<I: Into<String>>(self, default_mapping: I) -> Self
Set the fallback schema used when the discriminating property is missing or unmapped. Requires OpenAPI 3.2.
Sourcepub fn extensions(self, extensions: PropMap<String, Value>) -> Self
pub fn extensions(self, extensions: PropMap<String, Value>) -> Self
Add openapi extensions (x-something) for Discriminator.
Trait Implementations§
Source§impl Clone for Discriminator
impl Clone for Discriminator
Source§fn clone(&self) -> Discriminator
fn clone(&self) -> Discriminator
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Discriminator
impl Debug for Discriminator
Source§impl Default for Discriminator
impl Default for Discriminator
Source§fn default() -> Discriminator
fn default() -> Discriminator
Source§impl<'de> Deserialize<'de> for Discriminator
impl<'de> Deserialize<'de> for Discriminator
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Discriminator
Source§impl PartialEq for Discriminator
impl PartialEq for Discriminator
Source§impl Serialize for Discriminator
impl Serialize for Discriminator
impl StructuralPartialEq for Discriminator
Auto Trait Implementations§
impl Freeze for Discriminator
impl RefUnwindSafe for Discriminator
impl Send for Discriminator
impl Sync for Discriminator
impl Unpin for Discriminator
impl UnsafeUnpin for Discriminator
impl UnwindSafe for Discriminator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.