'How can i configure swagger3 to support https requests with @SecurityScheme

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?



Solution 1:[1]

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)));

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 pringi