java - 我可以使用自定义类作为 api 端点正文输入吗
问题描述
我正在使用 swagger 设置一个 api 端点,并且需要 body 类与 swagger 模型类相同,但是这样做会阻止端点工作。
@Operation(description = "body example is in model tab",
responses = {@ApiResponse(responseCode = "200", description =
"description") }, summary = "summary", tags = "Courier APIs")
@POST
@Secured
@Path("test")
@Consumes(MediaType.APPLICATION_XML)
@Produces(MediaType.APPLICATION_JSON)
public Response foo(
@RequestBody(required = true, content =
@Content(schema = @Schema(implementation = SwaggerMessages.class),
mediaType = "application/xml")) SwaggerMessages body) {
//do work with body
}
我希望能够将类的一些编码(即 json 的 xml)作为 resquest 主体发送,但是当我尝试向该端点发送请求时,它总是返回错误 500,甚至没有进入该方法
解决方案
推荐阅读
- javascript - 如何在不使用 JQuery 的情况下为滑块元素的每个值添加不同的标题(悬停文本)?
- java - 如何使用反射来执行泛型构造函数
- liferay - Liferay 7 中的方法 setSerial(boolean serial)
- visual-studio - Azure Function App not showing up in VS 2017
- android - My app gets killed due to Service App update
- javascript - 当拖放div行在jQuery中移动时如何禁用按钮
- wso2 - SSL certificate error on Nginx load balancer on WSO2 API cluster
- django - Django admin: Change the displayed value of a key
- python - 在 view.py 的打印输出中解析关键字后的成功消息
- android - How to disable ANR Watchdog when generating Trace Logs for Profiling after instrumenting my App?