#[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
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.
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: ServersAlternative Server array to serve all Operations in this PathItem overriding
the global server array.
parameters: ParametersList 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: OperationsMap 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
impl PathItem
Sourcepub fn new<O: Into<Operation>>(
path_item_type: PathItemType,
operation: O,
) -> Self
pub fn new<O: Into<Operation>>( path_item_type: PathItemType, operation: O, ) -> Self
Construct a new PathItem with provided Operation mapped to given PathItemType.
Sourcepub fn from_ref<S: Into<String>>(ref_location: S) -> Self
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");Sourcepub fn ref_location<S: Into<String>>(self, ref_location: S) -> Self
pub fn ref_location<S: Into<String>>(self, ref_location: S) -> Self
Set the $ref location for this PathItem and return self.
Sourcepub fn append(&mut self, other: &mut Self)
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.
Sourcepub fn add_operation<O: Into<Operation>>(
self,
path_item_type: PathItemType,
operation: O,
) -> Self
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.
Sourcepub fn add_additional_operation<M: Into<String>, O: Into<Operation>>(
self,
method: M,
operation: O,
) -> Self
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());Sourcepub fn summary<S: Into<String>>(self, summary: S) -> Self
pub fn summary<S: Into<String>>(self, summary: S) -> Self
Add or change summary intended to apply all operations in this PathItem.
Sourcepub fn description<S: Into<String>>(self, description: S) -> Self
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.
Sourcepub fn servers<I: IntoIterator<Item = Server>>(self, servers: I) -> Self
pub fn servers<I: IntoIterator<Item = Server>>(self, servers: I) -> Self
Sourcepub fn parameters<I: IntoIterator<Item = Parameter>>(
self,
parameters: I,
) -> Self
pub fn parameters<I: IntoIterator<Item = Parameter>>( self, parameters: I, ) -> Self
Trait Implementations§
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.
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.