Struct utoipa::openapi::server::Server

source ·
#[non_exhaustive]
pub struct Server { pub url: String, pub description: Option<String>, pub variables: Option<BTreeMap<String, ServerVariable>>, }
Expand description

Represents target server object. It can be used to alter server connection for path operations.

By default OpenAPI will implicitly implement Server with url = "/" if no servers is provided to the OpenApi.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§url: String

Target url of the Server. It can be valid http url or relative path.

Url also supports variable substitution with {variable} syntax. The substitutions then can be configured with Server::variables map.

§description: Option<String>

Optional description describing the target server url. Description supports markdown syntax.

§variables: Option<BTreeMap<String, ServerVariable>>

Optional map of variable name and its substitution value used in Server::url.

Implementations§

source§

impl Server

source

pub fn new<S: Into<String>>(url: S) -> Self

Construct a new Server with given url. Url can be valid http url or context path of the url.

If url is valid http url then all path operation request’s will be forwarded to the selected Server.

If url is path of url e.g. /api/v1 then the url will be appended to the servers address and the operations will be forwarded to location server address + url.

§Examples

Create new server with url path.

 Server::new("/api/v1");

Create new server with alternative server.

 Server::new("https://alternative.pet-api.test/api/v1");

Trait Implementations§

source§

impl Clone for Server

source§

fn clone(&self) -> Server

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Default for Server

source§

fn default() -> Server

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

impl<'de> Deserialize<'de> for Server

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl From<Server> for ServerBuilder

source§

fn from(value: Server) -> Self

Converts to this type from the input type.
source§

impl From<ServerBuilder> for Server

source§

fn from(value: ServerBuilder) -> Self

Converts to this type from the input type.
source§

impl PartialEq for Server

source§

fn eq(&self, other: &Server) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for Server

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Eq for Server

source§

impl StructuralPartialEq for Server

Auto Trait Implementations§

§

impl Freeze for Server

§

impl RefUnwindSafe for Server

§

impl Send for Server

§

impl Sync for Server

§

impl Unpin for Server

§

impl UnwindSafe for Server

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> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,