Interface ApiPath

All Superinterfaces:
NormalisedPath
All Known Implementing Classes:
ApiPathImpl

public interface ApiPath extends NormalisedPath
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 Type
    Method
    Description
    boolean
    hasParams(int index)
     
    boolean
    matches(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.
    boolean
    partMatches(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

      boolean matches(NormalisedPath requestPath)
      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

      boolean partMatches(int index, @Nonnull String requestPathPart)
      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 compare
      requestPathPart - 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

      List<String> paramNames(int index)
      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

      Map<String,Optional<String>> paramValues(int index, String requestPathPart)
      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 with
      requestPathPart - 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