Description
I am using Swagger OpenAPI 3 with Spring boot and OAuth2.0. I have following configuration for swagger
@OpenAPIDefinition(info = @Info(title = "REST API Documentation", version = "V1", description = "REST API Documentation"), servers = { @Server(url = "https://localhost:8080/api", description = "Test") } @SecurityScheme(name = "security_auth", type = SecuritySchemeType.OAUTH2, in = SecuritySchemeIn.HEADER, bearerFormat = "jwt", flows = @OAuthFlows(authorizationCode = @OAuthFlow(authorizationUrl = "${oAuthFlow.authorizationUrl}", tokenUrl = "${oAuthFlow.tokenUrl}", scopes = { @OAuthScope(name = "read", description = "read scope") }))) public class OpenApiConfig { }
Identity server is being used for authentication. Identity server expects the redirect URL to be 'https' but the redirect URL generated by swagger is 'http' ("https://localhost:8080/api/swagger-ui/oauth2-redirect.html") and hence fails to authenticate. I see that swagger is forming the URL with window.location.protol
I tried setting server variable in configuration which did not work
@Server(url = "https://localhost:8080/api", description = "Test", variables = { @ServerVariable(defaultValue = "protocol", name = "https") })