摇摇欲坠的注释内容类型未设置

时间:2018-08-20 15:02:11

标签: spring spring-boot kotlin swagger-ui springfox

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

@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

缺少什么?

1 个答案:

答案 0 :(得分:1)

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