Package com.networknt.openapi
Class ApiNormalisedPath
- java.lang.Object
-
- com.networknt.openapi.ApiNormalisedPath
-
- All Implemented Interfaces:
NormalisedPath
public class ApiNormalisedPath extends Object implements NormalisedPath
This utility normalize the RESTful API path so that they can be handled identically.- Author:
- Steve Hu
-
-
Constructor Summary
Constructors Constructor Description ApiNormalisedPath(String path, String basePath)Construct normalized path
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanisParam(int index)Stringnormalised()Stringoriginal()StringparamName(int index)Stringpart(int index)List<String>parts()
-
-
-
Constructor Detail
-
ApiNormalisedPath
public ApiNormalisedPath(String path, String basePath)
Construct normalized path- Parameters:
path- original pathbasePath- the path you want to overwrite - put null will use the base path parsed fromOpenApiHelper- put "" empty String will not trigger any overwrites - put regex will replace the first basePath with empty String
-
-
Method Detail
-
parts
public List<String> parts()
- Specified by:
partsin interfaceNormalisedPath- Returns:
- The path parts from the normalised path
-
part
public String part(int index)
- Specified by:
partin interfaceNormalisedPath- Parameters:
index- position of part- Returns:
- The path part at the given index
-
isParam
public boolean isParam(int index)
- Specified by:
isParamin interfaceNormalisedPath- Parameters:
index- position of part- Returns:
- Whether the path part at the given index is a path param (e.g. "/my/{param}/")
-
paramName
public String paramName(int index)
- Specified by:
paramNamein interfaceNormalisedPath- Parameters:
index- position of part- Returns:
- The parameter name of the path part at the given index, or
null
-
original
public String original()
- Specified by:
originalin interfaceNormalisedPath- Returns:
- The original, un-normalised path string
-
normalised
public String normalised()
- Specified by:
normalisedin interfaceNormalisedPath- Returns:
- The normalised path string, with prefixes removed and a standard treatment for leading/trailing slashed.
-
-