How to expose swagger UI endpoint in a microservice deployed within Cumulocity Tenant

I have configured my custom microservice to expose the Swagger UI and it works locally great, below find the screenshot

After deploying my microservice when trying to access the same URL I am getting below screen.

After further digging I found that it fails to get the swagger config

Any hint to resolve this would be appreciated.

Hi @Vachaspati_Diwevedi2,

It seems like your swagger UI is not aware that it is running behind a reverse proxy with a different path.
Therefore the UI tries to load the swagger-config from /v3/api-docs/swagger-config instead of /service/hello/swagger-ui/v3/api-docs/swagger-config or /service/hello/v3/api-docs/swagger-config. There is probably some option to configure this.

Btw: Hosting an UI from within a microservice is always a bit difficult as every request that goes to the microservice needs to be authorized, even for static assets like js files, images and stylesheets.
It might be easier to export the swagger config / OpenAPI spec after building the microservice and provide a separate UI app (Cumulocity hosted application) for viewing the the API.

Regards,
Tristan

1 Like