Package com.networknt.openapi
Class OpenApiHelper
- java.lang.Object
-
- com.networknt.openapi.OpenApiHelper
-
public class OpenApiHelper extends Object
This class load and cache openapi.json in a static block so that it can be shared by security for scope validation and validator for schema validation This handler supports openapi.yml, openapi.yaml and openapi.json and above is the loading sequence. Due to the high demand, we have changed this class from singleton to normal class to support multiple instances of specifications in light-rest-4j. Some of our users want to use one light-gateway to support multiple backend services to reduce the resource utilization.- Author:
- Steve Hu
-
-
Constructor Summary
Constructors Constructor Description OpenApiHelper(String spec)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Optional<NormalisedPath>findMatchingApiPath(NormalisedPath requestPath)static voidmerge(Map<String,Object> openapi, Map<String,Object> inject)merge inject map to openapi mapvoidsetBasePath(String basePath)This method should only be called in the multiple specification use case to set the base path based on the OpenApiHandler config with the pathSpecMapping.
-
-
-
Constructor Detail
-
OpenApiHelper
public OpenApiHelper(String spec)
-
-
Method Detail
-
merge
public static void merge(Map<String,Object> openapi, Map<String,Object> inject)
merge inject map to openapi map
-
findMatchingApiPath
public Optional<NormalisedPath> findMatchingApiPath(NormalisedPath requestPath)
-
setBasePath
public void setBasePath(String basePath)
This method should only be called in the multiple specification use case to set the base path based on the OpenApiHandler config with the pathSpecMapping. For single specification use case, this method should be called to overwrite the basePath from the handler.yml configuration in case the openapi.yaml cannot derive the basePath from the server section.- Parameters:
basePath- string
-
-