Struct salvo_oapi::schema::OneOf
source · #[non_exhaustive]pub struct OneOf {
pub items: Vec<RefOr<Schema>>,
pub schema_type: SchemaType,
pub title: Option<String>,
pub description: Option<String>,
pub default_value: Option<Value>,
pub examples: Vec<Value>,
pub discriminator: Option<Discriminator>,
pub extensions: Option<PropMap<String, Value>>,
}Expand description
OneOf Composite Object component holds multiple components together where API endpoint could return any of them.
See Schema::OneOf for more details.
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.items: Vec<RefOr<Schema>>Components of OneOf component.
schema_type: SchemaTypeType of OneOf e.g. SchemaType::basic(BasicType::Object) for object.
By default this is SchemaType::AnyValue as the type is defined by items
themselves.
title: Option<String>Changes the OneOf title.
description: Option<String>Description of the OneOf. Markdown syntax is supported.
default_value: Option<Value>Default value which is provided when user has not provided the input in Swagger UI.
examples: Vec<Value>Examples shown in UI of the value for richer documentation.
discriminator: Option<Discriminator>Optional discriminator field can be used to aid deserialization, serialization and validation of a specific schema.
extensions: Option<PropMap<String, Value>>Optional extensions x-something.
Implementations§
source§impl OneOf
impl OneOf
sourcepub fn new() -> Self
pub fn new() -> Self
Construct a new empty OneOf. This is effectively same as calling OneOf::default.
sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
sourcepub fn item<I: Into<RefOr<Schema>>>(self, component: I) -> Self
pub fn item<I: Into<RefOr<Schema>>>(self, component: I) -> Self
Adds a given Schema to OneOf Composite Object
sourcepub fn schema_type<T: Into<SchemaType>>(self, schema_type: T) -> Self
pub fn schema_type<T: Into<SchemaType>>(self, schema_type: T) -> Self
Add or change type of the object e.g. to change type to string
use value SchemaType::Type(Type::String).
sourcepub fn description(self, description: impl Into<String>) -> Self
pub fn description(self, description: impl Into<String>) -> Self
Add or change optional description for OneOf component.
sourcepub fn default_value(self, default: Value) -> Self
pub fn default_value(self, default: Value) -> Self
Add or change default value for the object which is provided when user has not provided the input in Swagger UI.
sourcepub fn example<V: Into<Value>>(self, example: V) -> Self
pub fn example<V: Into<Value>>(self, example: V) -> Self
Add or change example shown in UI of the value for richer documentation.
sourcepub fn examples<I: IntoIterator<Item = V>, V: Into<Value>>(
self,
examples: I,
) -> Self
pub fn examples<I: IntoIterator<Item = V>, V: Into<Value>>( self, examples: I, ) -> Self
Add or change examples shown in UI of the value for richer documentation.
sourcepub fn discriminator(self, discriminator: Discriminator) -> Self
pub fn discriminator(self, discriminator: Discriminator) -> Self
Add or change discriminator field of the composite OneOf type.
Trait Implementations§
source§impl<'de> Deserialize<'de> for OneOf
impl<'de> Deserialize<'de> for OneOf
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 StructuralPartialEq for OneOf
Auto Trait Implementations§
impl Freeze for OneOf
impl RefUnwindSafe for OneOf
impl Send for OneOf
impl Sync for OneOf
impl Unpin for OneOf
impl UnwindSafe for OneOf
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)