@JsonProperty无法正常工作于Spring Request

时间:2019-08-02 11:23:48

标签: java spring jackson swagger-2.0

在字段上应用@JsonProperty之后,我在spring请求中同时获得了字段名和属性名。

public class RequestDto {

    @JsonProperty("reference_id")
    private String referenceId;

    @JsonProperty("reference_type")
    private String referenceType;

    @JsonProperty("patient")
    private Patient patient;
}

public class Patient {

    @JsonProperty("birth_date")
    private String birthDate;

    @JsonProperty("first_name")
    private String firstName;

    @JsonProperty("last_name")
    private String lastName;
}

spring swagger请求中的转换如下

{
  "requestDto" : {
    "referenceId" : "string",
    "referenceType" : "string",
    "patient": {
      "birthDate": "string",
      "birth_date": "string",
      "firstName": "string",
      "first_name": "string",
      "lastName": "string",
      "last_name": "string",
    }
  }
}

0 个答案:

没有答案