#[non_exhaustive]pub struct Paths {
pub paths: BTreeMap<String, PathItem>,
pub extensions: Option<Extensions>,
}Expand description
OpenAPI types re-exported from utoipa for convenience. Implements OpenAPI Paths Object.
Holds relative paths to matching endpoints and operations. The path is appended to the url
from Server object to construct a full url for endpoint.
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.paths: BTreeMap<String, PathItem>§extensions: Option<Extensions>Optional extensions “x-something”.
Implementations§
Source§impl Paths
impl Paths
Sourcepub fn builder() -> PathsBuilder
pub fn builder() -> PathsBuilder
Construct a new PathsBuilder.
This is effectively same as calling PathsBuilder::new
Source§impl Paths
impl Paths
Sourcepub fn get_path_item<P>(&self, path: P) -> Option<&PathItem>
pub fn get_path_item<P>(&self, path: P) -> Option<&PathItem>
Return Option of reference to PathItem by given relative path P if one exists
in Paths::paths map. Otherwise will return None.
§Examples
Get user path item.
let path_item = paths.get_path_item("/api/v1/user");Sourcepub fn get_path_operation<P>(
&self,
path: P,
http_method: HttpMethod,
) -> Option<&Operation>
pub fn get_path_operation<P>( &self, path: P, http_method: HttpMethod, ) -> Option<&Operation>
Return Option of reference to Operation from map of paths or None if not found.
- First will try to find
PathItemby given relative pathPe.g."/api/v1/user". - Then tries to find
OperationfromPathItem’s operations by givenHttpMethod.
§Examples
Get user operation from paths.
let operation = paths.get_path_operation("/api/v1/user", HttpMethod::Get);Sourcepub fn add_path_operation<P, O>(
&mut self,
path: P,
http_methods: Vec<HttpMethod>,
operation: O,
)
pub fn add_path_operation<P, O>( &mut self, path: P, http_methods: Vec<HttpMethod>, operation: O, )
Append path operation to the list of paths.
Method accepts three arguments; path to add operation for, http_methods list of
allowed HTTP methods for the Operation and operation to be added under the path.
If path already exists, the provided Operation will be set to existing path item for
given list of HttpMethods.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Paths
impl<'de> Deserialize<'de> for Paths
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Paths, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Paths, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl From<PathsBuilder> for Paths
impl From<PathsBuilder> for Paths
Source§fn from(value: PathsBuilder) -> Paths
fn from(value: PathsBuilder) -> Paths
Source§impl Serialize for Paths
impl Serialize for Paths
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for Paths
Auto Trait Implementations§
impl Freeze for Paths
impl RefUnwindSafe for Paths
impl Send for Paths
impl Sync for Paths
impl Unpin for Paths
impl UnwindSafe for Paths
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)