8

I have a spring boot application with open-api 3 that is deployed in Kubernetes (spring-boot-starter-parent 2.2.4.RELEASE). The rest endpoints are accessible through ingress, so URL is something like:

https://host/ingress-path

I have the problem that as soon as the application is deployed to ingress, api-docs are available too via:

https://host/ingress-path/v3/api-docs

When I open Swagger UI I have 404 because it seems like Swagger UI is looking into https://host/v3/api-docs... When I open

https://host/ingress-path/swagger-ui/index.html

and put https://host/ingress-path/v3/api-docs to 'Expore' and run it, I have all my API discovered.

Can anybody suggest how to set a server for UI using some spring property, etc?

Currently I have this (downloaded from https://host/ingress-path/v3/api-docs.yaml)

openapi: 3.0.1
info:
  title: My API
  description: My API description
  version: v0.0.1
servers:
- url: https://host
  description: Generated server url

This API is autogenerated. I suppose that server has to have url: https://host/ingress-path

Seems like I need pathProvider with relative path, like described here:

https://github.com/springdoc/springdoc-openapi/issues/170

But I cannot find such thing in open-api 3.

Can you please help me?

Thanks!

P.S. I suppose that I can fix it via config:

springdoc:
  api-docs:
    enabled: true
    path: '/v3/api-docs'
  swagger-ui:
    path: '/swagger-ui'
    config-url: '/ingress-path/v3/api-docs/swagger-config'
    url: '/ingress-path/v3/api-docs'
    doc-expansion: none
    disable-swagger-default-url: true
Cunuu Kum
  • 161
  • 1
  • 2
  • 9

1 Answers1

5

Thanks Cunuu Kum

I tested your piece of code and confirm that it's working.

The key part is spring-ui.url

Reposting here so that it helps others

springdoc:
  api-docs:
    enabled: true
    path: '/v3/api-docs'
  swagger-ui:
    path: '/swagger-ui'
    config-url: '/ingress-path/v3/api-docs/swagger-config'
    url: '/ingress-path/v3/api-docs'
    doc-expansion: none
    disable-swagger-default-url: true
hacker
  • 342
  • 1
  • 4
  • 14