Struct salvo_oapi::Components
source · #[non_exhaustive]pub struct Components {
pub schemas: BTreeMap<String, RefOr<Schema>>,
pub responses: Responses,
pub security_schemes: BTreeMap<String, SecurityScheme>,
}Expand description
Implements OpenAPI Components Object which holds supported reusable objects.
Components can hold either reusable types themselves or references to other reusable types.
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.schemas: BTreeMap<String, RefOr<Schema>>Map of reusable OpenAPI Schema Objects.
responses: ResponsesMap of reusable response name, to OpenAPI Response Objects or OpenAPI References to OpenAPI Response Objects.
security_schemes: BTreeMap<String, SecurityScheme>Map of reusable OpenAPI Security Scheme Objects.
Implementations§
source§impl Components
impl Components
sourcepub fn new() -> Self
pub fn new() -> Self
Construct a new empty Components. This is effectively same as calling Components::default.
sourcepub fn add_security_scheme<N: Into<String>, S: Into<SecurityScheme>>(
self,
name: N,
security_schema: S
) -> Self
pub fn add_security_scheme<N: Into<String>, S: Into<SecurityScheme>>( self, name: N, security_schema: S ) -> Self
Add SecurityScheme to Components
Accepts two arguments where first is the name of the SecurityScheme. This is later when
referenced by SecurityRequirements. Second parameter is the SecurityScheme.
sourcepub fn add_security_schemes_from_iter<I: IntoIterator<Item = (N, S)>, N: Into<String>, S: Into<SecurityScheme>>(
self,
schemas: I
) -> Self
pub fn add_security_schemes_from_iter<I: IntoIterator<Item = (N, S)>, N: Into<String>, S: Into<SecurityScheme>>( self, schemas: I ) -> Self
Add iterator of SecuritySchemes to Components.
Accepts two arguments where first is the name of the SecurityScheme. This is later when
referenced by SecurityRequirements. Second parameter is the SecurityScheme.
sourcepub fn add_schema<S: Into<String>, I: Into<RefOr<Schema>>>(
self,
name: S,
schema: I
) -> Self
pub fn add_schema<S: Into<String>, I: Into<RefOr<Schema>>>( self, name: S, schema: I ) -> Self
Add Schema to Components.
Accepts two arguments where first is name of the schema and second is the schema itself.
sourcepub fn schemas_from_iter<I, C, S>(self, schemas: I) -> Selfwhere
I: IntoIterator<Item = (S, C)>,
C: Into<RefOr<Schema>>,
S: Into<String>,
pub fn schemas_from_iter<I, C, S>(self, schemas: I) -> Selfwhere I: IntoIterator<Item = (S, C)>, C: Into<RefOr<Schema>>, S: Into<String>,
sourcepub fn response<S: Into<String>, R: Into<RefOr<Response>>>(
self,
name: S,
response: R
) -> Self
pub fn response<S: Into<String>, R: Into<RefOr<Response>>>( self, name: S, response: R ) -> Self
Add a new response and returns self.
sourcepub fn extend_responses<I: IntoIterator<Item = (S, R)>, S: Into<String>, R: Into<RefOr<Response>>>(
self,
responses: I
) -> Self
pub fn extend_responses<I: IntoIterator<Item = (S, R)>, S: Into<String>, R: Into<RefOr<Response>>>( self, responses: I ) -> Self
Extends responses with the contents of an iterator.
sourcepub fn security_scheme<N: Into<String>, S: Into<SecurityScheme>>(
self,
name: N,
security_schema: S
) -> Self
pub fn security_scheme<N: Into<String>, S: Into<SecurityScheme>>( self, name: N, security_schema: S ) -> Self
Add SecurityScheme to Components.
Accepts two arguments where first is the name of the SecurityScheme. This is later when
referenced by SecurityRequirements. Second parameter is the SecurityScheme.
sourcepub fn append(&mut self, other: &mut Components)
pub fn append(&mut self, other: &mut Components)
Moves all elements from other into self, leaving other empty.
If a key from other is already present in self, the respective
value from self will be overwritten with the respective value from other.
Trait Implementations§
source§impl Clone for Components
impl Clone for Components
source§fn clone(&self) -> Components
fn clone(&self) -> Components
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for Components
impl Debug for Components
source§impl Default for Components
impl Default for Components
source§fn default() -> Components
fn default() -> Components
source§impl<'de> Deserialize<'de> for Components
impl<'de> Deserialize<'de> for Components
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>,
source§impl PartialEq<Components> for Components
impl PartialEq<Components> for Components
source§fn eq(&self, other: &Components) -> bool
fn eq(&self, other: &Components) -> bool
self and other values to be equal, and is used
by ==.