pub struct OpenApiService<T, W> { /* private fields */ }
Expand description

An OpenAPI service for Poem.

Implementations§

source§

impl<T> OpenApiService<T, ()>

source

pub fn new(api: T, title: impl Into<String>, version: impl Into<String>) -> Self

Create an OpenAPI container.

source§

impl<T, W> OpenApiService<T, W>

source

pub fn webhooks<W2>(self) -> OpenApiService<T, W2>

Sets the webhooks.

source

pub fn summary(self, summary: impl Into<String>) -> Self

Sets the summary of the API container.

source

pub fn description(self, description: impl Into<String>) -> Self

Sets the description of the API container.

source

pub fn terms_of_service(self, url: impl Into<String>) -> Self

Sets a URL to the Terms of Service for the API.

source

pub fn server(self, server: impl Into<ServerObject>) -> Self

source

pub fn contact(self, contact: ContactObject) -> Self

Sets the contact information for the exposed API.

source

pub fn license(self, license: impl Into<LicenseObject>) -> Self

Sets the license information for the exposed API.

Reference: https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#license-object

source

pub fn external_document(
    self,
    external_document: impl Into<ExternalDocumentObject>
) -> Self

source

pub fn extra_response_header<HT, H>(self, header: H) -> Selfwhere
    HT: Type,
    H: Into<ExtraHeader>,

Add extra response header

source

pub fn extra_request_header<HT, H>(self, header: H) -> Selfwhere
    HT: Type,
    H: Into<ExtraHeader>,

Add extra request header

source

pub fn cookie_key(self, key: CookieKey) -> Self

Sets the cookie key.

source

pub fn url_prefix(self, url_prefix: impl Into<String>) -> Self

Sets optional URl prefix to be added to path

source

pub fn openapi_explorer(&self) -> impl Endpointwhere
    T: OpenApi,
    W: Webhook,

Create the OpenAPI Explorer endpoint.

source

pub fn openapi_explorer_html(&self) -> Stringwhere
    T: OpenApi,
    W: Webhook,

Create the OpenAPI Explorer HTML

source

pub fn swagger_ui(&self) -> impl Endpointwhere
    T: OpenApi,
    W: Webhook,

Create the Swagger UI endpoint.

source

pub fn swagger_ui_html(&self) -> Stringwhere
    T: OpenApi,
    W: Webhook,

Create the Swagger UI HTML

source

pub fn rapidoc(&self) -> impl Endpointwhere
    T: OpenApi,
    W: Webhook,

Create the Rapidoc endpoint.

source

pub fn rapidoc_html(&self) -> Stringwhere
    T: OpenApi,
    W: Webhook,

Create the Rapidoc HTML

source

pub fn redoc(&self) -> impl Endpointwhere
    T: OpenApi,
    W: Webhook,

Create the Redoc endpoint.

source

pub fn redoc_html(&self) -> Stringwhere
    T: OpenApi,
    W: Webhook,

Create the Redoc HTML

source

pub fn spec_endpoint(&self) -> impl Endpointwhere
    T: OpenApi,
    W: Webhook,

Create an endpoint to serve the open api specification as JSON.

source

pub fn spec_endpoint_yaml(&self) -> impl Endpointwhere
    T: OpenApi,
    W: Webhook,

Create an endpoint to serve the open api specification as YAML.

source

pub fn spec(&self) -> Stringwhere
    T: OpenApi,
    W: Webhook,

Returns the OAS specification file as JSON.

source

pub fn spec_yaml(&self) -> Stringwhere
    T: OpenApi,
    W: Webhook,

Returns the OAS specification file as YAML.

Trait Implementations§

source§

impl<T: OpenApi, W: Webhook> IntoEndpoint for OpenApiService<T, W>

§

type Endpoint = Box<dyn Endpoint<Output = Response> + 'static, Global>

Represents the endpoint type.
source§

fn into_endpoint(self) -> Self::Endpoint

Converts this object into endpoint.

Auto Trait Implementations§

§

impl<T, W> RefUnwindSafe for OpenApiService<T, W>where
    T: RefUnwindSafe,
    W: RefUnwindSafe,

§

impl<T, W> Send for OpenApiService<T, W>where
    T: Send,
    W: Send,

§

impl<T, W> Sync for OpenApiService<T, W>where
    T: Sync,
    W: Sync,

§

impl<T, W> Unpin for OpenApiService<T, W>where
    T: Unpin,
    W: Unpin,

§

impl<T, W> UnwindSafe for OpenApiService<T, W>where
    T: UnwindSafe,
    W: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere
    T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere
    T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere
    T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> EndpointExt for Twhere
    T: IntoEndpoint,

source§

fn boxed<'a>(
    self
) -> Box<dyn Endpoint<Output = <Self::Endpoint as Endpoint>::Output> + 'a, Global>where
    Self: Sized + 'a,

Wrap the endpoint in a Box.
source§

fn with<T>(self, middleware: T) -> <T as Middleware<Self::Endpoint>>::Outputwhere
    T: Middleware<Self::Endpoint>,
    Self: Sized,

Use middleware to transform this endpoint. Read more
source§

fn with_if<T>(
    self,
    enable: bool,
    middleware: T
) -> EitherEndpoint<Self, <T as Middleware<Self::Endpoint>>::Output>where
    T: Middleware<Self::Endpoint>,
    Self: Sized,

if enable is true then use middleware to transform this endpoint. Read more
source§

fn data<T>(self, data: T) -> AddDataEndpoint<Self::Endpoint, T>where
    T: Clone + Send + Sync + 'static,
    Self: Sized,

Attach a state data to the endpoint, similar to with(AddData(T)). Read more
source§

fn data_opt<T>(
    self,
    data: Option<T>
) -> EitherEndpoint<AddDataEndpoint<Self::Endpoint, T>, Self>where
    T: Clone + Send + Sync + 'static,
    Self: Sized,

if data is Some(T) then attach the value to the endpoint.
source§

fn before<F, Fut>(self, f: F) -> Before<Self, F>where
    F: Fn(Request) -> Fut + Send + Sync,
    Fut: Future<Output = Result<Request, Error>> + Send,
    Self: Sized,

Maps the request of this endpoint. Read more
source§

fn after<F, Fut, T>(self, f: F) -> After<Self::Endpoint, F>where
    F: Fn(Result<<Self::Endpoint as Endpoint>::Output, Error>) -> Fut + Send + Sync,
    Fut: Future<Output = Result<T, Error>> + Send,
    T: IntoResponse,
    Self: Sized,

Maps the output of this endpoint. Read more
source§

fn around<F, Fut, R>(self, f: F) -> Around<Self::Endpoint, F>where
    F: Fn(Arc<Self::Endpoint>, Request) -> Fut + Send + Sync + 'static,
    Fut: Future<Output = Result<R, Error>> + Send + 'static,
    R: IntoResponse,
    Self: Sized,

Maps the request and response of this endpoint. Read more
source§

fn map_to_response(self) -> MapToResponse<Self::Endpoint>where
    Self: Sized,

Convert the output of this endpoint into a response. Response. Read more
source§

fn to_response(self) -> ToResponse<Self::Endpoint>where
    Self: Sized,

Convert the output of this endpoint into a response. Response. Read more
source§

fn map<F, Fut, R, R2>(self, f: F) -> Map<Self::Endpoint, F>where
    F: Fn(R) -> Fut + Send + Sync,
    Fut: Future<Output = R2> + Send,
    R: IntoResponse,
    R2: IntoResponse,
    Self: Sized,
    Self::Endpoint: Endpoint<Output = R> + Sized,

Maps the response of this endpoint. Read more
source§

fn and_then<F, Fut, R, R2>(self, f: F) -> AndThen<Self::Endpoint, F>where
    F: Fn(R) -> Fut + Send + Sync,
    Fut: Future<Output = Result<R2, Error>> + Send,
    R: IntoResponse,
    R2: IntoResponse,
    Self: Sized,
    Self::Endpoint: Endpoint<Output = R> + Sized,

Calls f if the result is Ok, otherwise returns the Err value of self. Read more
source§

fn catch_all_error<F, Fut, R>(self, f: F) -> CatchAllError<Self, F, R>where
    F: Fn(Error) -> Fut + Send + Sync,
    Fut: Future<Output = R> + Send,
    R: IntoResponse + Send,
    Self: Sized + Sync,

Catch all errors and convert it into a response. Read more
source§

fn catch_error<F, Fut, R, ErrType>(self, f: F) -> CatchError<Self, F, R, ErrType>where
    F: Fn(ErrType) -> Fut + Send + Sync,
    Fut: Future<Output = R> + Send,
    R: IntoResponse + Send + Sync,
    ErrType: Error + Send + Sync + 'static,
    Self: Sized,

Catch the specified type of error and convert it into a response. Read more
source§

fn inspect_all_err<F>(self, f: F) -> InspectAllError<Self, F>where
    F: Fn(&Error) + Send + Sync,
    Self: Sized,

Does something with each error. Read more
source§

fn inspect_err<F, ErrType>(self, f: F) -> InspectError<Self, F, ErrType>where
    F: Fn(&ErrType) + Send + Sync,
    ErrType: Error + Send + Sync + 'static,
    Self: Sized,

Does something with each specified error type. Read more
source§

impl<T> From<T> for T

const: unstable · 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 Twhere
    U: From<T>,

const: unstable · 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> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere
    U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere
    U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere
    V: MultiLane<T>,

§

fn vzip(self) -> V

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