Can't execute API with swagger ui behind NGINX Plus kubernetes ingress
- 6 years ago
I was able to get this working using a combination of the stand alone UI and the following code snippet in my SwaggerConfig.
// if running in kubernetes change the pathMapping and force https
// the KUBERNETES_SERVICE_HOST environment variable is always set by kubernetes.
// So I am using it to detect that we are running on kubernetes
// I then set the pathMapping to include the portion of the path that
// kubernetes prepends (in this case /dev/hell-world/hello )
// then I also force the protocol to HTTPS
if (System.getenv("KUBERNETES_SERVICE_HOST") != null) {
log.debug("Kubernetes detected! Setting pathMapping to: " + kubePath);
docket.pathMapping(kubePath);
docket.protocols(newHashSet("https"));
}