@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 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); }
.withBasePath(getBasePath(uriInfo)); swagger = new SwaggerContextService() .withServletConfig(sc) .withBasePath(getBasePath(uriInfo)) .getSwagger(); Set<Class<?>> classes; .withBasePath(getBasePath(uriInfo)) .updateSwagger(swagger);
SwaggerContextService ctxService = new SwaggerContextService() .withServletConfig(sc) .withBasePath(getBasePath(uriInfo));
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(); }