I want to configure the Servers dropdown in SwaggerUI to use the server urls specified in the yaml config. To start with I'm using this yaml configuration:
springdoc:
show-actuator: false
packagesToScan: .example.project
show-login-endpoint: false
swagger-ui:
path : /actuator/swagger-ui
api-docs:
path: /actuator/api-docs
@OpenAPIDefinition in the main application class only has info configured:
@OpenAPIDefinition(info = @Info(title = "ServiceAPI", version = "1.0", description = "Documentation API v1.0"))
This results in the the default generated server url: generated server url
I know I can hardcode the servers in @OpenAPIDefinition (and that works), but this isn't useful for me. I need to be able to take the servers from the yaml config.
If I understood the documentation correctly I should by able to just add them like this:
springdoc:
show-actuator: false
packagesToScan: .example.project
show-login-endpoint: false
swagger-ui:
path : /actuator/swagger-ui
api-docs:
path: /actuator/api-docs
servers:
- url:
description: Production Server
- url:
description: Staging Server
I also tried:
springdoc:
show-actuator: false
packagesToScan: .example.project
show-login-endpoint: false
open-api:
servers:
- url:
description: Production Server
- url:
description: Staging Server
swagger-ui:
path : /actuator/swagger-ui
api-docs:
path: /actuator/api-docs
With both of these the servers setting is completely ignored and I get the single default generated server url anyway. How do I get Swagger to use the servers provided in the yaml?
I'm using springdoc-openapi 2.6.0.