Configuring swagger-ui with server variable using configuration bean

Viewed 242

In my spring boot project, I have an openapi3 yaml definition of API used by swagger UI. I need to be able to dynamically change a part of server URL while using the UI and I was able to configure it in yaml

openapi: 3.0.1
info:
  title: Foo Service
  version: v1.0
servers:
  - url: https://{foo}.com
    variables:
      foo:
        default: bar

which makes the UI look like that swagger UI with server variable

Now, I'd like to stop using yamls to define my API and use annotations and configuration beans instead. I feel like the way to go would be to set servers field in io.swagger.v3.oas.models.OpenAPI bean, however I have no idea what to do considering I want the URL to be dynamically changed by the swagger UI.

Any guidance will be much appreciated

0 Answers
Related