我有这个 Spring 休息 Controller :
@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)接口(interface)测试此端点时,出现了415: content type invalid
错误。似乎 header 中未设置content-type: application/json
。有什么不见了 ?
最佳答案
HTTP GET请求中没有任何消耗。我认为您应该从consumes
和@GetMapping
中删除@ApiOperation
。