我可以使用自定义类作为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,甚至没有进入方法>

wunbin 回答:我可以使用自定义类作为api端点主体输入

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3165422.html

大家都在问