utoipa::openapi::schema

Struct Discriminator

Source
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

Source

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");
Source

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

Source§

fn clone(&self) -> Discriminator

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for Discriminator

Source§

fn default() -> Discriminator

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Discriminator

Source§

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

Source§

fn eq(&self, other: &Discriminator) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Discriminator

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for Discriminator

Source§

impl StructuralPartialEq for Discriminator

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,