pub struct OpenApiDefinition<'a, Context: ServerContext> { /* private fields */ }
Expand description

This object is used to specify configuration for building an OpenAPI definition document. It is constructed using ApiDescription::openapi(). Additional optional properties may be added and then the OpenAPI definition document may be generated via write() or json().

Implementations§

source§

impl<'a, Context: ServerContext> OpenApiDefinition<'a, Context>

source

pub fn description<S: AsRef<str>>(&mut self, description: S) -> &mut Self

Provide a short description of the API. CommonMark syntax may be used for rich text representation.

This routine will set the description field of the Info object in the OpenAPI definition.

source

pub fn terms_of_service<S: AsRef<str>>(&mut self, url: S) -> &mut Self

Include a Terms of Service URL for the API. Must be in the format of a URL.

This routine will set the termsOfService field of the Info object in the OpenAPI definition.

source

pub fn contact_name<S: AsRef<str>>(&mut self, name: S) -> &mut Self

Set the identifying name of the contact person or organisation responsible for the API.

This routine will set the name property of the Contact object within the Info object in the OpenAPI definition.

source

pub fn contact_url<S: AsRef<str>>(&mut self, url: S) -> &mut Self

Set a contact URL for the API. Must be in the format of a URL.

This routine will set the url property of the Contact object within the Info object in the OpenAPI definition.

source

pub fn contact_email<S: AsRef<str>>(&mut self, email: S) -> &mut Self

Set the email address of the contact person or organisation responsible for the API. Must be in the format of an email address.

This routine will set the email property of the Contact object within the Info object in the OpenAPI definition.

source

pub fn license<S1, S2>(&mut self, name: S1, url: S2) -> &mut Self
where S1: AsRef<str>, S2: AsRef<str>,

Provide the name of the licence used for the API, and a URL (must be in URL format) displaying the licence text.

This routine will set the name and optional url properties of the License object within the Info object in the OpenAPI definition.

source

pub fn license_name<S: AsRef<str>>(&mut self, name: S) -> &mut Self

Provide the name of the licence used for the API.

This routine will set the name property of the License object within the Info object in the OpenAPI definition.

source

pub fn json(&self) -> Result<Value>

Build a JSON object containing the OpenAPI definition for this API.

source

pub fn write(&self, out: &mut dyn Write) -> Result<()>

Build a JSON object containing the OpenAPI definition for this API and write it to the provided stream.

Auto Trait Implementations§

§

impl<'a, Context> !RefUnwindSafe for OpenApiDefinition<'a, Context>

§

impl<'a, Context> Send for OpenApiDefinition<'a, Context>

§

impl<'a, Context> Sync for OpenApiDefinition<'a, Context>

§

impl<'a, Context> Unpin for OpenApiDefinition<'a, Context>

§

impl<'a, Context> !UnwindSafe for OpenApiDefinition<'a, Context>

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.

§

impl<T> Instrument for T

§

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

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

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

§

type Output = T

Should always be Self
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.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T> ServerContext for T
where T: 'static + Send + Sync,