Struct salvo_oapi::schema::OneOf
source · #[non_exhaustive]pub struct OneOf {
pub items: Vec<RefOr<Schema>>,
pub title: Option<String>,
pub description: Option<String>,
pub default_value: Option<Value>,
pub example: Option<Value>,
pub discriminator: Option<Discriminator>,
pub nullable: bool,
}
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.
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.
example: Option<Value>
Example 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.
nullable: bool
Set true
to allow "null"
to be used as value for given type.
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 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(self, example: Value) -> Self
pub fn example(self, example: Value) -> Self
Add or change example 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.