未设置swagger注释内容类型

问题描述 投票:7回答:1

我有这个弹簧支架控制器:

@RestController
@RequestMapping("/communications")
class CommunicationController(private val service: CommunicationService) {

    @ApiOperation(
        produces = APPLICATION_JSON_VALUE, 
        consumes = APPLICATION_JSON_VALUE
    )
    @GetMapping(
        consumes = [APPLICATION_JSON_VALUE], 
        produces = [APPLICATION_JSON_VALUE]
    )
    fun findAll(
        criterias: CommunicationCriterias, 
        page: Pageable
    ): List<CommunicationDTO> = service.findCommunications(criterias, page)

}

[当我通过swagger-ui(springfox)接口测试此端点时,出现415: content type invalid错误。标题中似乎没有设置content-type: application/json

缺少什么?

spring spring-boot kotlin swagger-ui springfox
1个回答
0
投票

HTTP GET请求中没有任何消耗。我认为您应该从consumes@GetMapping中删除@ApiOperation

© www.soinside.com 2019 - 2024. All rights reserved.