pub struct Discriminator {
pub property_name: String,
pub mapping: BTreeMap<String, String>,
pub extensions: Option<Extensions>,
}
Expand description
OpenAPI Discriminator object which can be optionally used together with
OneOf
composite object.
Fields§
§property_name: String
Defines a discriminator property name which must be found within all composite objects.
mapping: BTreeMap<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.
extensions: Option<Extensions>
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 with_mapping<P: Into<String>, M: IntoIterator<Item = (K, V)>, K: Into<String>, V: Into<String>>(
property_name: P,
mapping: M,
) -> Self
pub fn with_mapping<P: Into<String>, M: IntoIterator<Item = (K, V)>, K: Into<String>, V: Into<String>>( property_name: P, mapping: M, ) -> Self
Construct a new Discriminator
object with property name and mappings.
Method accepts two arguments. First property_name
to use as discriminator
and
mapping
for custom property name mappings.
§Examples
Construct an ew Discriminator
with custom mapping.
let discriminator = Discriminator::with_mapping("pet_type", [
("cat","#/components/schemas/Cat")
]);
Trait Implementations§
Source§impl Clone for Discriminator
impl Clone for Discriminator
Source§fn clone(&self) -> Discriminator
fn clone(&self) -> Discriminator
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Default for Discriminator
impl Default for Discriminator
Source§fn default() -> Discriminator
fn default() -> Discriminator
Returns the “default value” for a type. Read more
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>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for Discriminator
impl PartialEq for Discriminator
Source§impl Serialize for Discriminator
impl Serialize for Discriminator
impl Eq 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 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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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
Compare self to
key
and return true
if they are equal.