Swagger UI accessed through docker does not work Swagger UI accessed through docker does not work docker docker

Swagger UI accessed through docker does not work


I finally found the problem: when executing using docker-compose, each microservice communicates to others using the service name, and docker-compose is able to translate that to the corresponding IP (that is the reason that in the second image, the Transactions link shows http://transactionservice/..., because in docker-compose.yml I was using that URL as the Resource URL).

So, when I access to swagger in ApiGateway, it returns that URL as the Resource. However, that html is being executed in my machine, not inside the docker, so when it tries to access to http://transactionservice/api/v2/api-docs, my machine does not know anything about transactionservice.

The solution was playing a bit with redirections in ApiGateway, using this configuration:

  zuul.routes.transaction.path: /transaction/**  zuul.routes.transaction.url: http://transactionservice/api/transaction  zuul.routes.transaction-swagger.path: /swagger/transaction/**  zuul.routes.transaction-swagger.url: http://transactionservice/api  zuul.routes.payment.path: /payment/**  zuul.routes.payment.url: http://paymentservice/api/payment  zuul.routes.payment-swagger.path: /swagger/payment/**  zuul.routes.payment-swagger.url: http://paymentservice/api  swagger.resources[0].name: transactions  swagger.resources[0].url: /swagger/transaction/v2/api-docs  swagger.resources[0].version: 2.0  swagger.resources[1].name: payments  swagger.resources[1].url: /swagger/payment/v2/api-docs  swagger.resources[1].version: 2.0

This way, all the requests are performed using the ApiGateway, even the swagger ones.