#[non_exhaustive]pub struct Components {
pub schemas: Schemas,
pub responses: Responses,
pub parameters: PropMap<String, RefOr<Parameter>>,
pub examples: PropMap<String, RefOr<Example>>,
pub request_bodies: PropMap<String, RefOr<RequestBody>>,
pub headers: PropMap<String, RefOr<Header>>,
pub security_schemes: PropMap<String, SecurityScheme>,
pub links: PropMap<String, RefOr<Link>>,
pub callbacks: PropMap<String, RefOr<Callback>>,
pub path_items: PropMap<String, RefOr<PathItem>>,
pub extensions: PropMap<String, Value>,
}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: SchemasMap of reusable OpenAPI Schema Objects.
responses: ResponsesMap of reusable response name, to OpenAPI Response Objects or OpenAPI References to OpenAPI Response Objects.
parameters: PropMap<String, RefOr<Parameter>>Map of reusable OpenAPI Parameter Objects, indexed by name.
examples: PropMap<String, RefOr<Example>>Map of reusable OpenAPI Example Objects, indexed by name.
request_bodies: PropMap<String, RefOr<RequestBody>>Map of reusable OpenAPI Request Body Objects, indexed by name.
headers: PropMap<String, RefOr<Header>>Map of reusable OpenAPI Header Objects, indexed by header name.
security_schemes: PropMap<String, SecurityScheme>Map of reusable OpenAPI Security Scheme Objects.
links: PropMap<String, RefOr<Link>>Map of reusable OpenAPI Link Objects, indexed by name.
callbacks: PropMap<String, RefOr<Callback>>Map of reusable OpenAPI Callback Objects, indexed by name.
path_items: PropMap<String, RefOr<PathItem>>Map of reusable OpenAPI Path Item Objects. Added in OpenAPI 3.1; entries
here can be referenced from paths or webhooks via RefOr::Ref.
extensions: PropMap<String, Value>Optional extensions “x-something”
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_scheme: S,
) -> Self
pub fn add_security_scheme<N: Into<String>, S: Into<SecurityScheme>>( self, name: N, security_scheme: S, ) -> Self
Add SecurityScheme to Components and returns Self.
Accepts two arguments: the name of the SecurityScheme (used later when referenced
by SecurityRequirements) and the SecurityScheme itself.
Sourcepub fn extend_security_schemes<I: IntoIterator<Item = (N, S)>, N: Into<String>, S: Into<SecurityScheme>>(
self,
schemas: I,
) -> Self
pub fn extend_security_schemes<I: IntoIterator<Item = (N, S)>, N: Into<String>, S: Into<SecurityScheme>>( self, schemas: I, ) -> Self
Add iterator of SecuritySchemes to Components.
Accepts two arguments: the name of the SecurityScheme (used later when referenced
by SecurityRequirements) and the SecurityScheme itself.
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 and returns Self.
Accepts two arguments where first is name of the schema and second is the schema itself.
Sourcepub fn extend_schemas<I, C, S>(self, schemas: I) -> Self
pub fn extend_schemas<I, C, S>(self, schemas: I) -> Self
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 add_parameter<N: Into<String>, P: Into<RefOr<Parameter>>>(
self,
name: N,
parameter: P,
) -> Self
pub fn add_parameter<N: Into<String>, P: Into<RefOr<Parameter>>>( self, name: N, parameter: P, ) -> Self
Sourcepub fn add_example<N: Into<String>, E: Into<RefOr<Example>>>(
self,
name: N,
example: E,
) -> Self
pub fn add_example<N: Into<String>, E: Into<RefOr<Example>>>( self, name: N, example: E, ) -> Self
Sourcepub fn add_request_body<N: Into<String>, B: Into<RefOr<RequestBody>>>(
self,
name: N,
request_body: B,
) -> Self
pub fn add_request_body<N: Into<String>, B: Into<RefOr<RequestBody>>>( self, name: N, request_body: B, ) -> Self
Insert a reusable RequestBody (or a Ref to one) and return self.
Sourcepub fn add_header<N: Into<String>, H: Into<RefOr<Header>>>(
self,
name: N,
header: H,
) -> Self
pub fn add_header<N: Into<String>, H: Into<RefOr<Header>>>( self, name: N, header: H, ) -> Self
Sourcepub fn add_callback<N: Into<String>, C: Into<RefOr<Callback>>>(
self,
name: N,
callback: C,
) -> Self
pub fn add_callback<N: Into<String>, C: Into<RefOr<Callback>>>( self, name: N, callback: C, ) -> Self
Sourcepub fn add_path_item<N: Into<String>, P: Into<RefOr<PathItem>>>(
self,
name: N,
path_item: P,
) -> Self
pub fn add_path_item<N: Into<String>, P: Into<RefOr<PathItem>>>( self, name: N, path_item: P, ) -> Self
Sourcepub fn append(&mut self, other: &mut Self)
pub fn append(&mut self, other: &mut Self)
Moves all elements from other into self, leaving other empty.
If a key from other is already present in self, the existing value is kept and
the duplicate from other is dropped.
Sourcepub fn extensions(self, extensions: PropMap<String, Value>) -> Self
pub fn extensions(self, extensions: PropMap<String, Value>) -> Self
Add openapi extensions (x-something) for Components.
Trait Implementations§
Source§impl Clone for Components
impl Clone for Components
Source§fn clone(&self) -> Components
fn clone(&self) -> Components
1.0.0 (const: unstable) · 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 for Components
impl PartialEq 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 ==.