Class 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 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
        Parameters:
        openapi - Map openapi
        inject - Map openapi
      • 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