Interface ApiPath
- All Superinterfaces:
NormalisedPath
- All Known Implementing Classes:
ApiPathImpl
Representation of a path within an OpenAPI / Swagger specification.
Has methods for extracting path params from path parts and comparing against a request path.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanhasParams(int index) booleanmatches(NormalisedPath requestPath) Determine if the given request path matches this API path, taking into consideration path params.paramNames(int index) paramValues(int index, String requestPathPart) Extract the param values for each param in the indexed path part, extracted from the given request path part.booleanpartMatches(int index, String requestPathPart) Determine if the given request path part matches against the corresponding path part in this API path, taking into consideration path params.Methods inherited from interface com.atlassian.oai.validator.model.NormalisedPath
normalised, numberOfParts, original, part
-
Method Details
-
matches
Determine if the given request path matches this API path, taking into consideration path params.Note that this method does not validate path params in the incoming request path part - it merely indicates that it matches the template described in the API path expression.
- Parameters:
requestPath- The request path to test- Returns:
- true if the incoming request path matches against the template defined in this API path; false otherwise.
-
partMatches
Determine if the given request path part matches against the corresponding path part in this API path, taking into consideration path params.Note that this method does not validate path params in the incoming request path part - it merely indicates that it matches the template described in the API path expression.
- Parameters:
index- The path part index to comparerequestPathPart- The request path part to match- Returns:
- true if the incoming request path part matches against the template defined in this API path; false otherwise.
- Throws:
IndexOutOfBoundsException- if the provided index is not a valid index
-
hasParams
boolean hasParams(int index) - Returns:
- Whether the path part at the given index contains one or more path params (e.g. "/my/{param}/")
- Throws:
IndexOutOfBoundsException- if the provided index is not a valid index
-
paramNames
- Returns:
- The parameter name(s) in the path part at the given index, or an empty list if the given part does not have a parameter. Parameter names are returned in order.
- Throws:
IndexOutOfBoundsException- if the provided index is not a valid index
-
paramValues
Extract the param values for each param in the indexed path part, extracted from the given request path part.- Parameters:
index- The index of the path part to extract templated params withrequestPathPart- The request path part to extract param values from- Returns:
- The (name, value) for each path param in the given part. If the param could not be found, will be empty.
- Throws:
IndexOutOfBoundsException- if the provided index is not a valid index
-