Java 虚张声势文档未正确表示大写字段
我遇到了一个特殊的问题,在招摇过市中,主要的大写字符被表示为小写。(此外,API识别XML请求的大写字母,但不识别JSON请求的大写字母) 控制器:Java 虚张声势文档未正确表示大写字段,java,json,xml,api,swagger,Java,Json,Xml,Api,Swagger,我遇到了一个特殊的问题,在招摇过市中,主要的大写字符被表示为小写。(此外,API识别XML请求的大写字母,但不识别JSON请求的大写字母) 控制器: @POST @Path("/search") @Consumes({"application/xml","application/json"}) @Produces({"application/xml","application/json"}) @ApiOperation(value = "value", notes = "notes", resp
@POST
@Path("/search")
@Consumes({"application/xml","application/json"})
@Produces({"application/xml","application/json"})
@ApiOperation(value = "value", notes = "notes", response = UpdateResponse.class, tags = {})
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Successful Response", response = UpdateResponse.class)
})
@RequestMapping(value = "/search",
method = RequestMethod.POST,
produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE},
consumes = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<UpdateResponse> search(
@ApiParam(value = "value", required = true) @Valid @RequestBody Request1 request1) {
UpdateResponse response = new UpdateResponse(request1.getIdentifier());
return new ResponseEntity(response, HttpStatus.OK);
}
Swagger JSON表示(API识别“identifer”标记):
招摇过市的XML表示(API无法识别“标识符”标记):
我需要API来识别以下XML请求,我需要swagger来生成它:
<?xml version="1.0" encoding="UTF-8"?>
<Request1>
<Identifier>string</Identifier>
</Request1>
一串
要让API理解大写的“Identifier”json标记,我需要做什么?要让swagger正确地为XML和json生成它,我需要做什么
如果我需要澄清我的问题,请告诉我
谢谢。简单修复,我所要做的就是将@JsonProperty(“标识符”)放在字段顶部:
@lombok.ToString
@lombok.Getter
@lombok.Setter
@lombok.Data
@ApiModel(description = "description.")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "Request1")
public class Request1 {
@XmlElement(name="Identifier")
@JsonProperty("Identifier") // <-- missing json property annotation added
@ApiModelProperty(required = true)
@Valid
private String identifier;
}
@lombok.ToString
@龙目格特
@龙目塞特
@龙目数据
@ApiModel(description=“description.”)
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name=“Request1”)
公共类请求1{
@xmlement(name=“Identifier”)
@JsonProperty(“标识符”)//
<?xml version="1.0" encoding="UTF-8"?>
<Request1>
<identifier>string</identifier>
</Request1>
{
"Identifier": "string"
}
<?xml version="1.0" encoding="UTF-8"?>
<Request1>
<Identifier>string</Identifier>
</Request1>
@lombok.ToString
@lombok.Getter
@lombok.Setter
@lombok.Data
@ApiModel(description = "description.")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "Request1")
public class Request1 {
@XmlElement(name="Identifier")
@JsonProperty("Identifier") // <-- missing json property annotation added
@ApiModelProperty(required = true)
@Valid
private String identifier;
}