Eko*_*ilo 5 jax-rs swagger swagger-2.0 swagger-editor swagger-codegen
我正在尝试使用 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,但它没有改变。
我如何使用注释来做到这一点?
| 归档时间: |
|
| 查看次数: |
7261 次 |
| 最近记录: |