swagger-2.0 - Swagger Annotations 不显示正文示例
问题描述
使用 Swagger Annotations 时,无法为请求正文创建示例。
这是 RESTful 资源/端点的注释内容:
@POST
@Path("/{carId}/conversation")
@ApiImplicitParams({
@ApiImplicitParam(name = "Authorization", value = "The AppJWT token", paramType = "header", required = true),
@ApiImplicitParam(name = "ON-BEHALF", value = "The ConsumerJWS token", paramType = "header", required = true),
@ApiImplicitParam(name = "v", value = "API version", defaultValue = "3", paramType = "query", required = true)
})
@ManagedAsync
@ApiOperation(value = "bla", notes = "")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "bla", response = CreateBlaResponse.class, responseContainer = "List"),
@ApiResponse(code = 400, message = "The input was invalid, please check.", response = GenericError.class),
@ApiResponse(code = 401, message = "Unauthorized. Are the headers correct?"),
@ApiResponse(code = 429, message = "Too many requests, please try again later", response = CreateConversationResBody.class)
})
public void createConversationBatchPOST(@ApiParam(value = "Car ID the action should apply to", required = true) @PathParam("carId") String carId,
@ApiParam(name = "body", value = "The Json payload", required = true, examples = @Example(value = {@ExampleProperty(value = "{\"name\" : \"James\"}", mediaType = "application/json")}))
@RequestBody String body,
@Suspended final AsyncResponse asyncResponse) throws IOException {
//.... implementation
}
你知道为什么方法签名中的注释
@ApiParam(name = "body", value = "The Json payload",
required = true, examples = @Example(value = {@ExampleProperty(value = "{\"name\" : \"James\"}", mediaType = "application/json")}))
@RequestBody String body
不会导致 Json 示例?
解决方案
推荐阅读
- sass - 为什么我们使用 #{} 进行插值?我们不能只使用 scss 变量吗?
- matlab - 为什么 GPU 上的隐式扩展并不总是更快?
- oracle - OracleDataReader GetValue 抛出 InvalidOperationException
- node.js - Tell ngix to send file from within node app with reverse proxy
- javascript - 为涉及 DataTypes.JSON 的序列化创建种子文件时出错
- python - 如何在 QScrollArea 中添加多个布局
- node.js - discord.js shard.broadcastEval 异步
- javascript - 取决于 R 闪亮应用程序中使用的绘图对象名称的神秘 javascript 错误
- c - 通用动态数组未正确更新属性
- azure - Azure Cosmos Db 如何在请求超过保留的 RU 时决定拒绝请求?