Java Swagger基本授权不使用@Api注释

Java Swagger基本授权不使用@Api注释,java,spring,spring-boot,swagger-ui,swagger-2.0,Java,Spring,Spring Boot,Swagger Ui,Swagger 2.0,Swagger基本授权不适用于@Api注释。但当与@Apioperation一起使用时,它可以正常工作。我希望在控制器级别而不是方法级别应用基本授权 这样使用: @RestController @Slf4j @Api(value="API related ",authorizations = {@Authorization(value="basicAuth")}) @RequestMapping(value="invoices",produces =MediaType.APPLICATION_J

Swagger基本授权不适用于@Api注释。但当与@Apioperation一起使用时,它可以正常工作。我希望在控制器级别而不是方法级别应用基本授权

这样使用:

@RestController
@Slf4j
@Api(value="API related ",authorizations = {@Authorization(value="basicAuth")})
@RequestMapping(value="invoices",produces =MediaType.APPLICATION_JSON_UTF8_VALUE)
@SuppressWarnings("rawtypes")
public class InvoiceController {


@SuppressWarnings("unchecked")
    @GetMapping
    @ApiOperation(value = "${InvoiceController.getAll.notes}", notes="${InvoiceController.getAll.notes}",response = Invoice.class)
    @ApiResponses(value = {@ApiResponse(code = 200, message = "Successfully retrieved list of invoices")})
    public  @ResponseBody ResponseEntity<Response> getAll(@Valid PaginationDto pagination,@Valid InvoiceFilterCriteriaDto filter) 
                    throws GenericServiceException{

}


}
@RestController
@Slf4j
@Api(value=“Api相关”,授权={@Authorization(value=“basicAuth”)})
@RequestMapping(value=“invoices”,products=MediaType.APPLICATION\uJSON\uUTF8\uvalue)
@抑制警告(“原始类型”)
公共类发票控制器{
@抑制警告(“未选中”)
@GetMapping
@ApiOperation(value=“${InvoiceController.getAll.notes}”,notes=“${InvoiceController.getAll.notes}”,response=Invoice.class)
@ApiResponse(值={@ApiResponse(code=200,message=“已成功检索发票列表”)})
public@responseBy ResponseEntity getAll(@Valid paginationTo pagination,@Valid InvoiceFilterCriteriaDto filter)
抛出GenericServiceException{
}
}
在main类中,通过提及基本身份创建了如下摘要:

        List<SecurityScheme> schemeList = new ArrayList<>();
        schemeList.add(new BasicAuth("basicAuth"));


        return new Docket(DocumentationType.SWAGGER_2)
                .forCodeGeneration(true)
                .produces(new HashSet<>(Arrays.asList( new String[] { MediaType.APPLICATION_JSON_UTF8_VALUE.toString()})))
                .apiInfo(apiInfo())
                .securitySchemes(schemeList)
List schemeList=new ArrayList();
schemeList.add(新BasicAuth(“BasicAuth”);
返回新摘要(DocumentationType.SWAGGER_2)
.forCodeGeneration(真)
.products(新的HashSet(Arrays.asList(新字符串[]{MediaType.APPLICATION_JSON_UTF8_VALUE.toString()})))
.apinfo(apinfo())
.证券计划(schemeList)

先给我们看一下代码!添加了招摇过市的代码先给我们看看代码!添加了“招摇过市”的代码