diff --git a/src/main/java/ru/reliabletech/zuul/swagger/props/ServiceInfo.java b/src/main/java/ru/reliabletech/zuul/swagger/props/ServiceInfo.java index 7d4e720..33c3eb6 100644 --- a/src/main/java/ru/reliabletech/zuul/swagger/props/ServiceInfo.java +++ b/src/main/java/ru/reliabletech/zuul/swagger/props/ServiceInfo.java @@ -19,6 +19,8 @@ class ServiceInfo { private String swaggerUri; + private String directSwaggerDocUrl; + private String protocol = ""; } \ No newline at end of file diff --git a/src/main/java/ru/reliabletech/zuul/swagger/props/ServicesSwaggerInfo.java b/src/main/java/ru/reliabletech/zuul/swagger/props/ServicesSwaggerInfo.java index cae14ae..14a857a 100644 --- a/src/main/java/ru/reliabletech/zuul/swagger/props/ServicesSwaggerInfo.java +++ b/src/main/java/ru/reliabletech/zuul/swagger/props/ServicesSwaggerInfo.java @@ -56,4 +56,9 @@ public Optional getServicePath(String route) { .map(ServiceInfo::getPath) .map(path -> path.replaceAll("^/", "").replaceAll("/\\*\\*", "")); } + + public Optional getDirectSwaggerDocUrl(String route) { + return Optional.ofNullable(routes.get(route)) + .map(ServiceInfo::getDirectSwaggerDocUrl); + } } \ No newline at end of file diff --git a/src/main/java/ru/reliabletech/zuul/swagger/service/GenericSwaggerService.java b/src/main/java/ru/reliabletech/zuul/swagger/service/GenericSwaggerService.java index 2148811..4f20c9c 100644 --- a/src/main/java/ru/reliabletech/zuul/swagger/service/GenericSwaggerService.java +++ b/src/main/java/ru/reliabletech/zuul/swagger/service/GenericSwaggerService.java @@ -49,11 +49,17 @@ public ObjectNode getSwaggerDoc(String route) { @Override public ObjectNode getOriginalSwaggerDoc(String route) { Optional serviceUrlOpt = servicesSwaggerInfo.getServiceUrl(route); - String serviceUrl = serviceUrlOpt.orElseGet(() -> servicesSwaggerInfo.getDefaultProtocol() + route); - RestTemplate restTemplate = serviceUrlOpt.map(x -> pureRestTemplate).orElse(loadBalancedRestTemplate); - String url = String.format("%s/%s", - serviceUrl, - servicesSwaggerInfo.getSwaggerUrl(route)); + RestTemplate restTemplate = serviceUrlOpt + .map(x -> pureRestTemplate) + .orElse(loadBalancedRestTemplate); + String url = servicesSwaggerInfo.getDirectSwaggerDocUrl(route) + .orElseGet(() -> { + String serviceUrl = serviceUrlOpt + .orElseGet(() -> servicesSwaggerInfo.getDefaultProtocol() + route); + return String.format("%s/%s", + serviceUrl, + servicesSwaggerInfo.getSwaggerUrl(route)); + }); try { return restTemplate.getForObject(url, ObjectNode.class); } catch (IllegalStateException e) {