【发布时间】:2021-04-01 02:14:14
【问题描述】:
无法解析引用,因为:无法解析指针:/definitions/错误不存在于文档中
我点击了这个链接http://www.baeldung.com/swagger-2-documentation-for-spring-rest-api,但是在我为自定义响应消息添加 globalResponseMessage() 方法时遇到了错误。我不明白是什么原因。 请帮忙....TIA
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build()
.apiInfo(apiInfo())
.consumes(getContentType())
.produces(getContentType())
.useDefaultResponseMessages(false)
.globalResponseMessage(RequestMethod.GET, newArrayList(
new ResponseMessageBuilder()
.code(500).message("500 message")
.responseModel(new ModelRef("Error")).build(),
new ResponseMessageBuilder()
.code(403)
.message("Forbidden!!!!!")
.build()));
}
【问题讨论】:
-
我遇到了同样的问题,并发现了一个建议 - github.com/springfox/springfox/issues/1443 在测试之前我与我的团队讨论过,我们不需要覆盖默认响应,所以我只是删除了它并没有测试 hydra 和 jonaskoperdraat 的建议
标签: java spring-mvc swagger-2.0