Struct utoipa::openapi::schema::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: 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.

source

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

source

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

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: Into<String>, R: Into<RefOr<Response>>>( self, name: S, response: R ) -> Self

source

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

source

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

source

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.

Trait Implementations§

source§

impl Default for ComponentsBuilder

source§

fn default() -> Self

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

impl From<Components> for ComponentsBuilder

source§

fn from(value: Components) -> Self

Converts to this type from the input type.
source§

impl From<ComponentsBuilder> for Components

source§

fn from(value: ComponentsBuilder) -> 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>,

§

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

§

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.