首页 > 解决方案 > Camel REST DSL 招摇输出包含无效的 responseSchema 元素

问题描述

我正在使用 spring-boot (2.0.5) 和 camel (2.22.1) 开发一个 REST API。API 是使用 Camel 出色的 REST DSL 定义和自动记录的。一切都很好,除了当我检查生成的招摇(JSON 或 YAML)时,我的响应包含一个无效属性responseSchema,它似乎是schema我期望的有效属性的副本。这会在通过 swagger-ui 渲染时导致验证错误。

这是我的 API 定义示例:

rest("/things")
.get("/").outType(Thing[].class)
.param().name("param1").type(RestParamType.query).required(FALSE)
  .description("param 1").endParam()

.responseMessage().code(200).message("Some things..")
  .header("number-of-things").dataType("integer").endHeader()
  .endResponseMessage()

.responseMessage().code(400)
  .message("Bad request.")
  .responseModel(Error.class).endResponseMessage()

responses这在我的招摇部分产生以下输出:

400:
  description: "Bad request."
  schema:
    $ref: "#/definitions/Error"
  responseSchema:
    $ref: "#/definitions/Error"

看起来我遇到了这个问题,并且有一些解决这个问题的建议,但我不确定在 SpringBoot 应用程序中哪个更可取,而且我还没有任何解决方案可以工作。

标签: javarestspring-bootapache-camelswagger

解决方案


我遇到了同样的问题,经过调查我发现它是骆驼虫,所以创建了问题,你可以看到描述https://issues.apache.org/jira/browse/CAMEL-13340。它将从骆驼 2.23.2 修复


推荐阅读