Skip to content

Fix for @JsonProperty annotation#440

Closed
kendzi wants to merge 1 commit intoswagger-api:masterfrom
kendzi:fix_for_JsonProperty
Closed

Fix for @JsonProperty annotation#440
kendzi wants to merge 1 commit intoswagger-api:masterfrom
kendzi:fix_for_JsonProperty

Conversation

@kendzi
Copy link

@kendzi kendzi commented Jan 23, 2014

  1. Annotation from field are not read when @JsonProperty annotation is on getter, because it take name from annotation on getter and search for wrong field name.

Current model of parsing annotation on Model class is as follow:

  • Read annotations from getter, if there is @JsonProperty replace getter name with value of annotation
  • Read annotation from field. Field name is resolved from getter name or wrongly taken from value of @JsonProperty if it existed on getter,

Example:

@JsonProperty("access_token")
public String getAccessToken() {
 return accessToken;
}

It is try to find property with name access_token not accessToken.

  1. It is not possible to use annotation @JsonProperty on field, only on method, because name from getter is resolved in first place:
@JsonProperty("access_token")
@ApiModelProperty(value = "The access token.", required = true)
private String accessToken;

I add patch which solve both problems.

@fehguy
Copy link
Contributor

fehguy commented Jan 23, 2014

if you can make this pull request into the develop branch, I can verify it.

@fehguy
Copy link
Contributor

fehguy commented Mar 20, 2014

HI, I believe this is merged into the develop branch and will be released in 1.3.3

@fehguy fehguy closed this Mar 20, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants