utoipa::openapi::example

Struct ExampleBuilder

source
pub struct ExampleBuilder { /* private fields */ }
Expand description

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

§Examples

Construct a new Example via builder

let example = ExampleBuilder::new()
    .summary("Example string response")
    .value(Some(serde_json::json!("Example value")))
    .build();

Implementations§

source§

impl ExampleBuilder

source

pub fn new() -> ExampleBuilder

Constructs a new ExampleBuilder.

source

pub fn build(self) -> Example

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

source§

impl ExampleBuilder

source

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

Add or change a short description for the Example. Setting this to empty String will make it not render in the generated OpenAPI document.

source

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

Add or change a long description for the Example. Markdown syntax is supported for rich text representation.

Setting this to empty String will make it not render in the generated OpenAPI document.

source

pub fn value(self, value: Option<Value>) -> Self

Add or change embedded literal example value. Example::value and Example::external_value are mutually exclusive.

source

pub fn external_value<E: Into<String>>(self, external_value: E) -> Self

Add or change an URI that points to a literal example value. Example::external_value provides the capability to references an example that cannot be easily included in JSON or YAML. Example::value and Example::external_value are mutually exclusive.

Setting this to an empty String will make the field not to render in the generated OpenAPI document.

Trait Implementations§

source§

impl Default for ExampleBuilder

source§

fn default() -> Self

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

impl From<Example> for ExampleBuilder

source§

fn from(value: Example) -> Self

Converts to this type from the input type.
source§

impl From<ExampleBuilder> for Example

source§

fn from(value: ExampleBuilder) -> Self

Converts to this type from the input type.
source§

impl From<ExampleBuilder> for RefOr<Example>

source§

fn from(example_builder: ExampleBuilder) -> 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>,

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.