Skip to main content

PathItem

Struct PathItem 

Source
#[non_exhaustive]
pub struct PathItem { pub ref_location: Option<String>, pub summary: Option<String>, pub description: Option<String>, pub servers: Servers, pub parameters: Parameters, pub operations: Operations, pub additional_operations: PropMap<String, Operation>, pub extensions: PropMap<String, Value>, }
Expand description

Implements OpenAPI Path Item Object what describes Operations available on a single path.

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.
§ref_location: Option<String>

External reference to a Path Item Object defined elsewhere.

In OpenAPI 3.1 a Path Item Object can carry its own $ref field that delegates to another Path Item definition. When set, sibling fields’ behavior is undefined per spec — most consumers resolve the reference and ignore them.

See https://spec.openapis.org/oas/v3.1.0#path-item-object.

§summary: Option<String>

Optional summary intended to apply all operations in this PathItem.

§description: Option<String>

Optional description intended to apply all operations in this PathItem. Description supports markdown syntax.

§servers: Servers

Alternative Server array to serve all Operations in this PathItem overriding the global server array.

§parameters: Parameters

List of Parameters common to all Operations in this PathItem. Parameters cannot contain duplicate parameters. They can be overridden in Operation level but cannot be removed there.

§operations: Operations

Map of operations in this PathItem. Operations can hold only one operation per PathItemType.

§additional_operations: PropMap<String, Operation>

Operations on this path that use an HTTP method with no dedicated field, e.g. a custom or registered extension method. Added in OpenAPI 3.2.

The key is the HTTP method with the exact capitalization sent in the request (e.g. PURGE). Methods that already have a dedicated field must not appear here — use PathItem::operations for those.

See https://spec.openapis.org/oas/v3.2.0.html#path-item-object.

§extensions: PropMap<String, Value>

Optional extensions “x-something”

Implementations§

Source§

impl PathItem

Source

pub fn new<O: Into<Operation>>( path_item_type: PathItemType, operation: O, ) -> Self

Construct a new PathItem with provided Operation mapped to given PathItemType.

Source

pub fn from_ref<S: Into<String>>(ref_location: S) -> Self

Construct a PathItem that is purely a reference to another Path Item, e.g. one defined under components.pathItems.

let item = PathItem::from_ref("#/components/pathItems/PingWebhook");
Source

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

Set the $ref location for this PathItem and return self.

Source

pub fn append(&mut self, other: &mut Self)

Moves all elements from other into self, leaving other empty.

If a key from other is already present in self, the respective value from self will be overwritten with the respective value from other.

Source

pub fn add_operation<O: Into<Operation>>( self, path_item_type: PathItemType, operation: O, ) -> Self

Append a new Operation by PathItemType to this PathItem. Operations can hold only one operation per PathItemType.

Source

pub fn add_additional_operation<M: Into<String>, O: Into<Operation>>( self, method: M, operation: O, ) -> Self

Append an Operation for an HTTP method that has no dedicated Path Item field, e.g. a custom method. Requires OpenAPI 3.2.

method must be the HTTP method with the exact capitalization sent in the request, and must not be one of the methods covered by PathItemType.

let item = PathItem::default().add_additional_operation("PURGE", Operation::new());
Source

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

Add or change summary intended to apply all operations in this PathItem.

Source

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

Add or change optional description intended to apply all operations in this PathItem. Description supports markdown syntax.

Source

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

Add list of alternative Servers to serve all Operations in this PathItem overriding the global server array.

Source

pub fn parameters<I: IntoIterator<Item = Parameter>>( self, parameters: I, ) -> Self

Append list of Parameters common to all Operations to this PathItem.

Source

pub fn extensions(self, extensions: PropMap<String, Value>) -> Self

Add openapi extensions (x-something) for PathItem.

Trait Implementations§

Source§

impl Clone for PathItem

Source§

fn clone(&self) -> PathItem

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for PathItem

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for PathItem

Source§

fn default() -> PathItem

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

impl<'de> Deserialize<'de> for PathItem

Deserializing a PathItem cannot be derived: the operation map and the extension map are both flattened, so serde would hand every unmatched key to both of them and an operation such as get would end up duplicated in extensions, making the value re-serialize with repeated keys. Partition the keys explicitly instead.

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 PartialEq for PathItem

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl Serialize for PathItem

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 StructuralPartialEq for PathItem

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

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

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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 = !

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

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