#[non_exhaustive]pub struct Paths {
pub paths: PathsMap<String, PathItem>,
pub extensions: Option<Extensions>,
}
Expand description
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: PathsMap<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: AsRef<str>>(&self, path: P) -> Option<&PathItem>
pub fn get_path_item<P: AsRef<str>>(&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: AsRef<str>>(
&self,
path: P,
http_method: HttpMethod,
) -> Option<&Operation>
pub fn get_path_operation<P: AsRef<str>>( &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
PathItem
by given relative pathP
e.g."/api/v1/user"
. - Then tries to find
Operation
fromPathItem
’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: AsRef<str>, O: Into<Operation>>(
&mut self,
path: P,
http_methods: Vec<HttpMethod>,
operation: O,
)
pub fn add_path_operation<P: AsRef<str>, O: Into<Operation>>( &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 HttpMethod
s.