首页 > 解决方案 > 如何使用 Swagger 显示骆驼休息参数 List of Objects

问题描述

如何让camel-swagger-java扫描骆驼休息 api 路由并表示休息端点参数,该参数是那些 pojo 具有 json 属性的 pojo 对象列表?

当尝试使用 List 或 SamplePojo[] 作为骆驼休息端点主体时,camel-swagger-java 使用两者.type(SamplePojo[].class).typeList(SamplePojo.class)生成一个 api 页面,该页面显示主体只是一个字符串,而不是为 SamplePojo 中的所有属性显示 json班级。

有一个 .arrayType 方法可以用于路由参数,但没有提到应该指定什么: .arrayType("whatHere?")

在下面使用它的尝试大摇大摆地将类型显示为一个字符串,而不是 json 属性:

.arrayType(SamplePojo.class.getName())

休息操作参数定义

/**
 * Sets the Swagger Parameter array type.
 * Required if data type is "array". Describes the type of items in the array.
 */
public void setArrayType(String arrayType) {
    this.arrayType = arrayType;
}

有人问这个没有解决方案:

https://camel.465427.n5.nabble.com/How-to-get-long-and-array-data-types-working-in-camel-swagger-java-td5775343.html

有 swagger 的骆驼示例,但没有 List 参数示例:

https://github.com/Talend/apache-camel/blob/master/examples/camel-example-swagger-cdi/src/main/java/org/apache/camel/example/cdi/UserRouteBuilder.java

标签: javarestapache-camelswagger

解决方案


推荐阅读