1

I use Open Api:

        <dependency>
            <groupId>org.springdoc</groupId>
            <artifactId>springdoc-openapi-ui</artifactId>
            <version>1.6.9</version>
        </dependency>

This is how the swagger ui looks like:

enter image description here

Is there some setting for it to generate a secure url? how do I simply overwrite the base path all together (for example via application.properties

Diana
  • 935
  • 10
  • 31

2 Answers2

0

@Ray is right. But the domain is hidden.
https://stackoverflow.com/a/74261128/20325718

enter image description here

If you also want to display the domain, you can try the following method.

@Configuration
public class OpenAPIDefinitionConfiguration {
  @Component
  @Profile("prd")
  @OpenAPIDefinition(servers = @Server(url = "https://example.com"))
  public static class PrdOpenAPIDefinitionConfiguration {
  }

  @Component
  @Profile("local")
  @OpenAPIDefinition(servers = @Server(url = "https://local.example.com"))
  public static class LocalOpenAPIDefinitionConfiguration {
  }
}

application.properties

spring.profiles.active=prd

Or if you want to display all environments, you can also display it by the following method.

@OpenAPIDefinition(
        servers = {
                @Server(
                        url = "https://{profile}.example.com/",
                        variables = {
                                @ServerVariable(
                                        name = "profile",
                                        allowableValues = { "prd", "local" },
                                        defaultValue = "prd"
                                )
                        }
                )
        }
)
YutaSaito
  • 387
  • 6
0

I met the same problem after updating an app. My solution was to add into my nginx config proxy_set_header X-Forwarded-Proto https;

Hanna
  • 1
  • 1
  • 1
    I took the suggestion from here: https://github.com/springdoc/springdoc-openapi/issues/171 and https://gist.github.com/kuleszaj/1911050 – Hanna Dec 28 '22 at 09:48