我正在尝试使用 json 正文的示例来记录 api 错误响应。我找不到示例或合适的注释。使用 swagger 编辑器,我至少可以获得一些看起来像我想要实现的结果的东西。
responses:
'200' :
description: Request completed with no errors
examples:
application/json: {"result" : { "id": "blue" }}
Run Code Online (Sandbox Code Playgroud)
库是 swagger-core 1.6.0
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-core</artifactId>
<scope>compile</scope>
<version>1.6.0</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
端点是使用 jax-rs 创建的。
我对端点做了这个
@ApiResponses(value = {
@ApiResponse(code = 200, message = "OK",
examples = @Example(value = @ExampleProperty(mediaType = "application/json", value = "{\"result\" : { \"id\": \"blue\" }}"))
)
})
public Response getResult(){}
Run Code Online (Sandbox Code Playgroud)
生成的 swagger.json 没有所需的
examples:
application/json: {"result" : { "id": "blue" }}
Run Code Online (Sandbox Code Playgroud)
我也尝试传递response = ApiResponse.class、Examples.class和Example.class,但它没有改变。 …
我有数据表示为正双数列表,以及包含将用于分组数据的间隔的列表.间隔始终排序.
我尝试使用以下实现对数据进行分组
List<Double> data = DoubleStream.generate(new Random()::nextDouble).limit(10).map(d -> new Random().nextInt(30) * d).boxed().collect(Collectors.toList());
HashMap<Integer, List<Double>> groupped = new HashMap<Integer, List<Double>>();
data.stream().forEach(d -> {
groupped.merge(getGroup(d, group), new ArrayList<Double>(Arrays.asList(d)), (l1, l2) -> {
l1.addAll(l2);
return l1;
});
});
public static Integer getGroup(double data, List<Integer> group) {
for (int i = 1; i < group.size(); i++) {
if (group.get(i) > data) {
return group.get(i - 1);
}
}
return group.get(group.size() - 1);
}
public static List<Integer> group() {
List<Integer> groups = new LinkedList<Integer>();
//can …Run Code Online (Sandbox Code Playgroud)