Swagger UI 示例数据 [英] Swagger UI example data

查看:75
本文介绍了Swagger UI 示例数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法大摇大摆地显示示例数据;模型,输入和输出、查询参数、标题等?我在注释文档中找不到与此相关的任何内容;https://github.com/swagger-api/swagger-core/wiki/Annotations-1.5.X

Is there a way in swagger to show example data for; model, both input & output, query parameters, headers, etc? I have been unable to find anything related to this in the annotations documentation; https://github.com/swagger-api/swagger-core/wiki/Annotations-1.5.X

推荐答案

如果您查看 wiki 中提到的某些注释的文档,您将看到它们的可选参数中有一个称为 exampleexamples.您可以使用此参数添加一个或多个示例(如果允许).

If you look at the documentation for some of the annotations mentioned in the wiki you will see they have among their optional parameters one called example or examples. You can use this parameter to add a single example or more than one (if it's allowed).

例如,对于查询参数,您可以使用 @ApiParam 注释:

For example for a query parameter you can do it like this using the @ApiParam annotation:

@Path("/{username}")
@ApiOperation(value = "Updated user")
public Response updateUser(
  @ApiParam(example = "moondaisy") @QueryParam("username") String username
) {
...
}

这篇关于Swagger UI 示例数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆