title: Swagger UI try It! does not work with Kubernetes ingress
body: <p>We have a Java Spring Boot project with Swagger and docker. We deploy it on kubernetes behind an ingress controller.</p>
  
  <p>It works properly in localhost (using postman and swagger-ui try button).
  Problem comes when we deploy it.</p>
  
  <p>Rest Controller:</p>
  
  <pre><code>@ApiOperation(value = "Operation", 
            notes = "it does something&lt;br /&gt;")
  @RequestMapping(value="/operation", method=RequestMethod.POST)
  @ApiResponses({
      @ApiResponse(code = 200, message = "OK")
  })
  @ResponseBody public ResponseEntity&lt;String&gt; operation(@RequestBody BodyThing thing) {
  
      return new ResponseEntity&lt;&gt;("OK", HttpStatus.OK);
  } //operation
  </code></pre>
  
  <p>Now the ingress:</p>
  
  <pre><code>apiVersion: extensions/v1beta1
  kind: Ingress
  
  metadata:
    name: myapp-ingress
    namespace: __NAMESPACE__
    annotations:
      kubernetes.io/ingress.class: nginx
      nginx.ingress.kubernetes.io/rewrite-target: /
  
  spec:
    tls:
    - hosts:
      - test.host.com
      secretName: key-pair
    rules:
    - host: test.host.com
  
  
  http:
    paths:
    - path: /myapp
      backend:
        serviceName: myapp-service
        servicePort: 8080
  </code></pre>
  
  <p>Then, with the app online deployed on K8S, usign an app like postman we must call:
  <a href="https://test.host.com/myapp/operation" rel="noreferrer">https://test.host.com/myapp/operation</a> in order to call the API. It works OK.</p>
  
  <p>The problem comes if we enter in Swagger UI portal: <a href="https://test.host.com/myapp/swagger-ui.html" rel="noreferrer">https://test.host.com/myapp/swagger-ui.html</a></p>
  
  <p>If we try the API call inside the swagger UI, it tries to call to <a href="https://test.host.com/operation" rel="noreferrer">https://test.host.com/operation</a> and it fails with 404 code.</p>
  
  <p>Swagger-UI makes the Endpoint URL with: host + basepath + operation_path and that is: test.host.com + / + operation</p>
  
  <p>It doesnt aggregate ingress path.</p>
  
  <p>How can we deal with it?
  Of course is something that only happends if we deploy it with the ingress controller because, we add the /myapp path.</p>
  
  <p>Thanks!</p>