Struct OpenApiBuilder

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

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

§Examples

Create OpenApi using OpenApiBuilder.

let openapi = OpenApiBuilder::new()
     .info(Info::new("My api", "1.0.0"))
     .paths(Paths::new())
     .components(Some(
         Components::new()
     ))
     .build();

Implementations§

Source§

impl OpenApiBuilder

Source

pub fn new() -> OpenApiBuilder

Constructs a new OpenApiBuilder.

Source

pub fn build(self) -> OpenApi

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

Source§

impl OpenApiBuilder

Source

pub fn info<I>(self, info: I) -> OpenApiBuilder
where I: Into<Info>,

Add Info metadata of the API.

Source

pub fn servers<I>(self, servers: Option<I>) -> OpenApiBuilder
where I: IntoIterator<Item = Server>,

Add iterator of Servers to configure target servers.

Source

pub fn paths<P>(self, paths: P) -> OpenApiBuilder
where P: Into<Paths>,

Add Paths to configure operations and endpoints of the API.

Source

pub fn components(self, components: Option<Components>) -> OpenApiBuilder

Add Components to configure reusable schemas.

Source

pub fn security<I>(self, security: Option<I>) -> OpenApiBuilder

Add iterator of SecurityRequirements that are globally available for all operations.

Source

pub fn tags<I>(self, tags: Option<I>) -> OpenApiBuilder
where I: IntoIterator<Item = Tag>,

Add iterator of Tags to add additional documentation for operations tags.

Source

pub fn external_docs( self, external_docs: Option<ExternalDocs>, ) -> OpenApiBuilder

Add ExternalDocs for referring additional documentation.

Source

pub fn schema<S>(self, schema: S) -> OpenApiBuilder
where S: Into<String>,

Override default $schema dialect for the Open API doc.

§Examples

Override default schema dialect.

let _ = OpenApiBuilder::new()
    .schema("http://json-schema.org/draft-07/schema#")
    .build();

Trait Implementations§

Source§

impl Default for OpenApiBuilder

Source§

fn default() -> OpenApiBuilder

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

impl From<OpenApi> for OpenApiBuilder

Source§

fn from(value: OpenApi) -> OpenApiBuilder

Converts to this type from the input type.
Source§

impl From<OpenApiBuilder> for OpenApi

Source§

fn from(value: OpenApiBuilder) -> OpenApi

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,