Struct ComponentsBuilder

Source
pub struct ComponentsBuilder<S: State = Empty> { /* private fields */ }
Expand description

Use builder syntax to set the inputs and finish with build().

Implementations§

Source§

impl<S: State> ComponentsBuilder<S>

Source

pub fn build(self) -> Components
where S: IsComplete,

Finish building and return the requested object

Source

pub fn extensions( self, value: impl Into<Extensions>, ) -> ComponentsBuilder<SetExtensions<S>>
where S::Extensions: IsUnset,

Optional (Some / Option setters).

Optional extensions “x-something”.

Source

pub fn maybe_extensions( self, value: Option<impl Into<Extensions>>, ) -> ComponentsBuilder<SetExtensions<S>>
where S::Extensions: IsUnset,

Optional (Some / Option setters).

Optional extensions “x-something”.

Source§

impl<S: State> ComponentsBuilder<S>

Source

pub fn schema(self, name: impl Into<String>, schema: impl Into<Schema>) -> Self

Add Schema to Components.

Accepts two arguments where first is name of the schema and second is the schema itself.

Source

pub fn schemas_from_iter<I: IntoIterator<Item = (S2, C)>, C: Into<Schema>, S2: Into<String>>( self, schemas: I, ) -> Self

Add Schemas from iterator.

§Examples
Components::builder().schemas_from_iter([(
    "Pet",
    Schema::from(
        Object::builder()
            .property(
                "name",
                Object::builder().schema_type(Type::String),
            )
            .required(["name"])
    ),
)]);
Source

pub fn response<S2: Into<String>, R: Into<RefOr<Response>>>( self, name: S2, response: R, ) -> Self

Add Response to Components.

Method accepts tow arguments; name of the reusable response and response which is the reusable response itself.

Source

pub fn responses_from_iter<I: IntoIterator<Item = (S2, R)>, S2: Into<String>, R: Into<RefOr<Response>>>( self, responses: I, ) -> Self

Add multiple Responses to Components from iterator.

Like the ComponentsBuilder::schemas_from_iter this allows adding multiple responses by any iterator what returns tuples of (name, response) values.

Source

pub fn security_scheme<N: Into<String>, S2: Into<SecurityScheme>>( self, name: N, security_scheme: S2, ) -> 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.

Trait Implementations§

Source§

impl<S: IsComplete> From<ComponentsBuilder<S>> for Components

Source§

fn from(value: ComponentsBuilder<S>) -> Self

Converts to this type from the input type.

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> 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, 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.