new SwaggerContextService().withServletConfig(config).updateSwagger(swagger);
public void setScan(boolean shouldScan) { scanAndRead(); new SwaggerContextService() .withConfigId(configId) .withScannerId(scannerId) .withContextId(contextId) .withServletConfig(servletConfig) .withSwaggerConfig(this) .withScanner(this) .withBasePath(getBasePath()) .withPathBasedConfig(isUsePathBasedConfig()) .initConfig() .initScanner(); }
SwaggerContextService ctxService = new SwaggerContextService() .withServletConfig(sc) .withBasePath(getBasePath(uriInfo)); Scanner scanner = ctxService.getScanner(); if (scanner != null) { SwaggerSerializers.setPrettyPrint(scanner.getPrettyPrint()); swagger = new SwaggerContextService() .withServletConfig(sc) .withBasePath(getBasePath(uriInfo)) .getSwagger(); Set<Class<?>> classes; if (scanner instanceof JaxrsScanner) { swagger = ((SwaggerConfig) scanner).configure(swagger); } else { SwaggerConfig swaggerConfig = ctxService.getConfig(); if (swaggerConfig != null) { LOGGER.debug("configuring swagger with " + swaggerConfig); new SwaggerContextService() .withServletConfig(sc) .withBasePath(getBasePath(uriInfo)) .updateSwagger(swagger); if (SwaggerContextService.isScannerIdInitParamDefined(sc)) { initializedScanner.put(sc.getServletName() + "_" + SwaggerContextService.getScannerIdFromInitParam(sc), true); } else if (SwaggerContextService.isConfigIdInitParamDefined(sc)) { initializedConfig.put(sc.getServletName() + "_" + SwaggerContextService.getConfigIdFromInitParam(sc), true);
HttpHeaders headers, UriInfo uriInfo) { SwaggerContextService ctxService = new SwaggerContextService() .withServletConfig(sc) .withBasePath(getBasePath(uriInfo)); Swagger swagger = ctxService.getSwagger(); synchronized (ApiListingResource.class) { if (SwaggerContextService.isScannerIdInitParamDefined(sc)) { if (!initializedScanner.containsKey(sc.getServletName() + "_" + SwaggerContextService.getScannerIdFromInitParam(sc))) { swagger = scan(app, servletContext, sc, uriInfo); if (SwaggerContextService.isConfigIdInitParamDefined(sc)) { if (!initializedConfig.containsKey(sc.getServletName() + "_" + SwaggerContextService.getConfigIdFromInitParam(sc))) { swagger = scan(app, servletContext, sc, uriInfo); } else if (SwaggerContextService.isUsePathBasedConfigInitParamDefined(sc)) { if (!initializedConfig.containsKey(sc.getServletName() + "_" + ctxService.getBasePath())) { swagger = scan(app, servletContext, sc, uriInfo);
@Override public void init(ServletConfig servletConfig) throws javax.servlet.ServletException { super.init(servletConfig); String basePath = null; if (SwaggerContextService.isServletConfigAvailable(servletConfig)) { basePath = servletConfig.getInitParameter("swagger.api.basepath"); if (basePath != null) { String[] parts = basePath.split("://"); if (parts.length > 1) { int pos = parts[1].indexOf("/"); if (pos >= 0) { basePath = parts[1].substring(pos); } else { basePath = null; } } } } new SwaggerContextService().withServletConfig(servletConfig).withBasePath(basePath).initConfig().initScanner(); ReaderConfigUtils.initReaderConfig(servletConfig); }
public SwaggerContextService initConfig() { return initConfig(null); }
@Inject public SwaggerServletConfig(ServletContext context, Configuration config) { this.context = context; // Copy swagger properties to init params config.getProperties() .entrySet() .stream() .filter(entry -> entry.getKey().startsWith(PROPERTY_PREFIX)) .filter(entry -> entry.getValue() != null) .forEach(entry -> initParams.put(entry.getKey(), entry.getValue().toString())); Function<String, String> getValue = name -> { Object val = config.getProperty(name); return val == null ? null : val.toString(); }; new SwaggerContextService() .withConfigId(getValue.apply(CONFIG_ID_KEY)) .withScannerId(getValue.apply(SCANNER_ID_KEY)) .withContextId(getValue.apply(CONTEXT_ID_KEY)) .withBasePath(context.getContextPath()) .withSwaggerConfig(new DefaultSwaggerConfig(context)) .withServletConfig(this) .initConfig() .initScanner(); }
@Override public void init(ServletConfig config) throws ServletException { Info info = new Info() .title("Swagger Server") .description("List of admin REST APIs for the pravega controller service.") .termsOfService("") .contact(new Contact() .email("")) .license(new License() .name("Apache 2.0") .url("http://www.apache.org/licenses/LICENSE-2.0")); ServletContext context = config.getServletContext(); Swagger swagger = new Swagger().info(info); new SwaggerContextService().withServletConfig(config).updateSwagger(swagger); } }
new SwaggerContextService().withServletConfig(config).updateSwagger(swagger);