public OpenAPIConfiguration customize(final OpenAPIConfiguration configuration) { if (configuration == null) { return configuration; } if (dynamicBasePath) { final MessageContext ctx = createMessageContext(); // If the JAX-RS application with custom path is defined, it might be present twice, in the // request URI as well as in each resource operation URI. To properly represent server URL, // the application path should be removed from it. final String url = StringUtils.removeEnd( StringUtils.substringBeforeLast(ctx.getUriInfo().getRequestUri().toString(), "/"), applicationPath); final Collection<Server> servers = configuration.getOpenAPI().getServers(); if (servers == null || servers.stream().noneMatch(s -> s.getUrl().equalsIgnoreCase(url))) { configuration.getOpenAPI().setServers(Collections.singletonList(new Server().url(url))); } } return configuration; }
public OpenAPIConfiguration customize(final OpenAPIConfiguration configuration) { if (configuration == null) { return configuration; } if (dynamicBasePath) { final MessageContext ctx = createMessageContext(); // If the JAX-RS application with custom path is defined, it might be present twice, in the // request URI as well as in each resource operation URI. To properly represent server URL, // the application path should be removed from it. final String url = StringUtils.removeEnd( StringUtils.substringBeforeLast(ctx.getUriInfo().getRequestUri().toString(), "/"), applicationPath); final Collection<Server> servers = configuration.getOpenAPI().getServers(); if (servers == null || servers.stream().noneMatch(s -> s.getUrl().equalsIgnoreCase(url))) { configuration.getOpenAPI().setServers(Collections.singletonList(new Server().url(url))); } } return configuration; }