1

I have updated my project to Springboot version 2.6.3 and swagger 3. I need to support authorize HTTPS requests but @SecurityScheme supports only https requests. Is there a way to configure @SecurityScheme annotation to support https requests or any other solution?

James Z
  • 12,209
  • 10
  • 24
  • 44
prathyaksh
  • 21
  • 5
  • Do you mean http? Now you're saying you want https, but it only supports https. – James Z Feb 22 '22 at 15:52
  • i want it other way around. locally I see HTTP and I want to hit from the server with HTTPS, but on server, it is showing HTTP – M-sAnNan Jun 09 '22 at 14:36

1 Answers1

2

It is the server URL that "dictates" if is to be used http or https. Type.HTTP only refers to the security scheme type. To use HTTPS change the Server URL to be https.

Example:

        return new OpenAPI().servers(List.of(new Server()
    .url("https://google.com")))
    .components(new Components()
        .addSecuritySchemes("xpto",
            new SecurityScheme()
                .type(Type.HTTP)));
pringi
  • 3,987
  • 5
  • 35
  • 45