public void onStartup(Set<Class<?>> classes, ServletContext servletContext) throws ServletException { if (classes != null && classes.size() != 0) { Set<Class<?>> resources = new LinkedHashSet(); classes.stream() .filter(c -> ignored.stream().noneMatch(i -> c.getName().startsWith(i))) .forEach(resources::add); if (!resources.isEmpty()) { // init context try { SwaggerConfiguration oasConfig = new SwaggerConfiguration() .resourceClasses(resources.stream().map(c -> c.getName()).collect(Collectors.toSet())); new JaxrsOpenApiContextBuilder() .openApiConfiguration(oasConfig) .buildContext(true); } catch (OpenApiConfigurationException e) { throw new RuntimeException(e.getMessage(), e); } } } }
protected OpenAPIConfiguration loadConfiguration() throws OpenApiConfigurationException { Map<String, OpenApiConfigurationLoader> loaders = getLocationLoaders(); try { if (StringUtils.isNotEmpty(configLocation)) { if (loaders.get("classpath").exists(configLocation)) { return loaders.get("classpath").load(configLocation); } if (loaders.get("file").exists(configLocation)) { return loaders.get("file").load(configLocation); } } // check known locations List<ImmutablePair<String, String>> knownLocations = getKnownLocations(); for (ImmutablePair<String, String> location : knownLocations) { if (loaders.get(location.left).exists(location.right)) { try { return loaders.get(location.left).load(location.right); } catch (IOException ioe) { // try next one } } } return null; } catch (Exception e) { throw new OpenApiConfigurationException(e.getMessage(), e); } }
@Override public void init(ServletConfig config) throws ServletException { super.init(config); String ctxId = getContextIdFromServletConfig(config); try { new ServletOpenApiContextBuilder() .servletConfig(config) .ctxId(ctxId) .buildContext(true); } catch (OpenApiConfigurationException e) { e.printStackTrace(); } }
return map; } catch (OpenApiConfigurationException e) { throw new Exception("Error resolving API specification: " + e.getMessage(), e); } catch (Exception e) { throw new Exception("Error resolving API specification: " + e.getMessage(), e);
throw new OpenApiConfigurationException("error initializing context: " + e.getMessage(), e); throw new OpenApiConfigurationException("error configuring objectMapper: " + e.getMessage(), e); throw new OpenApiConfigurationException("error configuring model converters: " + e.getMessage(), e);
@Override public void init(ServletConfig config) throws ServletException { super.init(config); String ctxId = getContextIdFromServletConfig(config); try { new ServletOpenApiContextBuilder() .servletConfig(config) .ctxId(ctxId) .buildContext(true); } catch (OpenApiConfigurationException e) { e.printStackTrace(); } }
throw new MojoFailureException(e.getMessage(), e); } catch (IOException e) { getLog().error( "Error writing API specification" , e);
protected OpenAPIConfiguration loadConfiguration() throws OpenApiConfigurationException { Map<String, OpenApiConfigurationLoader> loaders = getLocationLoaders(); try { if (StringUtils.isNotEmpty(configLocation)) { if (loaders.get("classpath").exists(configLocation)) { return loaders.get("classpath").load(configLocation); } if (loaders.get("file").exists(configLocation)) { return loaders.get("file").load(configLocation); } } // check known locations List<ImmutablePair<String, String>> knownLocations = getKnownLocations(); for (ImmutablePair<String, String> location : knownLocations) { if (loaders.get(location.left).exists(location.right)) { try { return loaders.get(location.left).load(location.right); } catch (IOException ioe) { // try next one } } } return null; } catch (Exception e) { throw new OpenApiConfigurationException(e.getMessage(), e); } }
return map; } catch (OpenApiConfigurationException e) { throw new Exception("Error resolving API specification: " + e.getMessage(), e); } catch (Exception e) { throw new Exception("Error resolving API specification: " + e.getMessage(), e);
throw new OpenApiConfigurationException("error initializing context: " + e.getMessage(), e); throw new OpenApiConfigurationException("error configuring objectMapper: " + e.getMessage(), e); throw new OpenApiConfigurationException("error configuring model converters: " + e.getMessage(), e);