cancel
Showing results for 
Search instead for 
Did you mean: 

Add basic authentication in swagger-ui in project with Spring-security

Occasional Contributor

Add basic authentication in swagger-ui in project with Spring-security

Hi,

 

I want to add the functionality to authenticate in swagger-ui in order to test protected endpoints.

In previous project with old swagger version and spring-boot with spring-mvc I was able to do that, but I don't know how to do this with my new project.

 

I'm using :

Spring-boot 2 with spring-security and spring-boot-starter-jersey

swagger 2.0.6 (swagger core v3 with swagger-jaxrs2)

swagger 3.20.3

 

Thanks for your help !

1 REPLY 1
Highlighted
Occasional Contributor

Re: Add basic authentication in swagger-ui in project with Spring-security

I think I've found the solution :

 

Adding

@SecurityScheme(name = "myHttpSecurity",
        type = SecuritySchemeType.HTTP,
        in = SecuritySchemeIn.HEADER
        )

Then, the authorize button appears Smiley Happy

Now, I still have to find how to print description about security informations in swagger-ui

New Here?
Join us and watch the welcome video:
6 / 7 API Testing Mistakes Video