ComponentsBuilder

Struct ComponentsBuilder 

Source
pub struct ComponentsBuilder { /* private fields */ }
Expand description

Builder for Components with chainable configuration methods to create a new Components.

Implementations§

Source§

impl ComponentsBuilder

Source

pub fn new() -> ComponentsBuilder

Constructs a new ComponentsBuilder.

Source

pub fn build(self) -> Components

Constructs a new Components taking all fields values from this object.

Source§

impl ComponentsBuilder

Source

pub fn schema<S, I>(self, name: S, schema: I) -> ComponentsBuilder
where S: Into<String>, I: Into<RefOr<Schema>>,

Add Schema to Components.

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

Source

pub fn schema_from<'s, I>(self) -> ComponentsBuilder
where I: ToSchema<'s>,

Source

pub fn schemas_from_iter<I, C, S>(self, schemas: I) -> ComponentsBuilder
where I: IntoIterator<Item = (S, C)>, C: Into<RefOr<Schema>>, S: Into<String>,

Add Schemas from iterator.

§Examples
ComponentsBuilder::new().schemas_from_iter([(
    "Pet",
    Schema::from(
        ObjectBuilder::new()
            .property(
                "name",
                ObjectBuilder::new().schema_type(SchemaType::String),
            )
            .required("name")
    ),
)]);
Source

pub fn response<S, R>(self, name: S, response: R) -> ComponentsBuilder
where S: Into<String>, R: Into<RefOr<Response>>,

Source

pub fn response_from<'r, I>(self) -> ComponentsBuilder
where I: ToResponse<'r>,

Source

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

Source

pub fn security_scheme<N, S>( self, name: N, security_schema: S, ) -> ComponentsBuilder
where N: Into<String>, S: Into<SecurityScheme>,

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 Default for ComponentsBuilder

Source§

fn default() -> ComponentsBuilder

Returns the “default value” for a type. Read more
Source§

impl From<Components> for ComponentsBuilder

Source§

fn from(value: Components) -> ComponentsBuilder

Converts to this type from the input type.
Source§

impl From<ComponentsBuilder> for Components

Source§

fn from(value: ComponentsBuilder) -> Components

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.