9

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
2
  • Did you get the solution? Commented Jun 1, 2021 at 14:36
  • 1
    Hi @Varun. Actually I posted possible solution. I did not really tested it because we decided that we don't need it on our service. Commented Jun 15, 2021 at 19:24

1 Answer 1

10

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
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.