.securitySchemes(Collections.singletonList(securityScheme())) .securityContexts(Collections.singletonList(securityContext()));
private SecurityScheme securityScheme() { //return new ApiKey("Authorization", "Authorization", "header"); return new ApiKey("X-Token", "X-Token", "header"); } private SecurityContext securityContext() { return SecurityContext.builder() .securityReferences(defaultAuth()) .forPaths(PathSelectors.regex("^(?!auth).*$")) .build(); } private List<SecurityReference> defaultAuth() { AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything"); AuthorizationScope[] authorizationScopes = new AuthorizationScope[1]; authorizationScopes[0] = authorizationScope; return Collections.singletonList( new SecurityReference("X-Token", authorizationScopes)); }