【发布时间】:2019-01-26 17:59:19
【问题描述】:
我有这个弹簧休息控制器:
@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。
缺少什么?
【问题讨论】:
-
你使用哪个版本的 swagger?
-
我使用了
io.springfox:springfox-swagger2:2.9.2和io.springfox:springfox-swagger-ui:2.9.2但我最终删除了 de springfox 依赖项并使用了经典的 swagger 编辑器... -
我在 springfox-swagger2+springfox-swagger-ui v 2.9.2 遇到了同样的问题
-
了解这是一个旧帖子,但有人刚刚发布了一个对我有用的答案,所以在这里发布以供参考:stackoverflow.com/questions/62078786/…
标签: spring spring-boot kotlin swagger-ui springfox