我的Spring Boot应用程序在ReqGetActive
请求主体中有一个模型类@PostMapping
用作请求模型。
控制器:
@PostMapping(value = "/api/getActive",
consumes = "application/JSON",
produces = "application/JSON")
public ResponseEntity<String> getActive(
@ApiParam(value = "Consumer's request body", required = true)
@RequestBody ReqGetActive jsonPojo) throws Exception {
return null;
}
ReqGetActive:
import lombok.*;
import com.fasterxml.jackson.annotation.*;
public class ReqGetActive {
@JsonProperty("RequestData")
@JsonFormat(with = JsonFormat.Feature.ACCEPT_CASE_INSENSITIVE_PROPERTIES)
private RequestData RequestData;
@Getter @Setter @ToString
@JsonIgnoreProperties(ignoreUnknown = true)
private static class RequestData{
@JsonProperty("ReportTitle")
@JsonFormat(with = JsonFormat.Feature.ACCEPT_CASE_INSENSITIVE_PROPERTIES)
private String ReportTitle;
}
}
它在swagger-ui中显示请求模型,如下所示: swagger-ui-screenshot.png
现在我的疑问是,正如您在上图中看到的那样,类ReqGetActive字段的数据类型显示为json字段的值。
在json模型中是否可以仅将键和值显示为""
?
P.s:我只使用swagger批注在swagger-ui中显示
答案 0 :(得分:0)
我已经使用@ApiModelProperty设置了所需的值,以将其更改为所需的值。 @ApiModelProperty(example =“ [ExampleTitle]”)private String ReportTitle;
即,我可以设置“”或null以外的任何值