I am trying to do swagger Integration in my application. So for that I have added this in build.gradle.
implementation 'org.springdoc:springdoc-openapi-ui:1.6.9'
This is in MyApplication.java
@OpenAPIDefinition(info = @Info(title = “Backend API", version = "2.0", description = "Backend Details"),
servers = {@Server(url= "https://"+"${server.DNSName}"+"${server.servlet.contextPath}")}
)
@SecurityScheme(name = "Authorization", scheme = "bearer", type = SecuritySchemeType.APIKEY, in = SecuritySchemeIn.HEADER)
Now when I am accusing this api : http://localhost:8080/swagger-ui.html I am getting
{"timeStamp":null,"error":"AUTH TOKEN MISSING","code":null,"fieldErrors":null,"objectErrors":null}
This the place where I am getting error
@Override
public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response)
throws AuthenticationException {
Authentication auth = null;
User user = null;
Object uuid = request.getSession().getAttribute("uuid");
if (uuid != null) {
try {
user = userService.findByAuthenticityToken(uuid.toString());
user.setAuthType(AuthenticationType.valueOf(request.getSession().getAttribute("authenticationType").toString()));
log.info("Retrieved User From Session --> " + user);
CurrentUserContext.setCurrentUser(user);
auth = new UsernamePasswordAuthenticationToken(user, null, user.getAuthorities());
} catch (ResourceNotFoundException e) {
log.error(e.getMessage(), e);
}
} else {
log.info("No User Found with uuid");
}
if (isSessionRequest(request) && auth == null) {
auth = new UsernamePasswordAuthenticationToken(null, null, null);
}
if (auth == null) {
throw new BadCredentialsException("AUTH TOKEN MISSING");
}
return auth;
}
This is what I have given in application.yml
springdoc:
swagger-ui:
path: /swagger-ui-custom.html
I am using Spring 2.7.1 which I need to migrate to Spring 3.0 in later.