-
Notifications
You must be signed in to change notification settings - Fork 472
Consider @JsonProperty-defined property name for affordance metadata #1563
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
name
field in DefaultMetadataProperty to the value of a @JsonProperty if an annotation is present else, use the field name.
name
field in DefaultMetadataProperty to the value of a @JsonProperty if an annotation is present else, use the field name.
Would you mind taking a step back and describing the actual problem to be solved? |
For example, I have a DTO that is used in a public class AddPoliticianDTORequest {
@JsonProperty("first_name")
String firstName;
@JsonProperty("last_name")
String lastName; Spring MVC expects the body of the POST method to have json values of first_name and last_name. If I were to make an affordance for this in a Hal+Form mediatype, the resulting data would be: "templates":{
"default":{
"method":"post",
"properties":[
{
"name":"firstName",
.......
},
{
"name":"lastName",
.......
}
],
"target":"http://localhost:8080/api/politician/politicians"
}
} The response would ultimately break your clients that use your api since you expect first_name and last_name instead of "firstName" and "lastName" all because of the @JsonProperty. The name of the property values should always be the value of a @JsonProperty annotation when it is present and if not, use the default field name. |
Awesome, thanks for the additional context. |
We now consider Jackson's @JsonProperty annotation to rename PropertyMetadata instances accordingly. Original pull request: #1594.
This method is currently used in test cases only and the just introduced ability to rename property makes the method not reliably usable as the way it is named doesn't convey which name is to be used. It currently is the potentially renamed value. Moving to the actual property name as input creates stronger boundaries to assume a type backing the metadata, which we want to avoid.
Make the default name or value of the field
name
of theDefaultMetadataProperty
to the value that is present in the @JsonProperty annotation else, use the default field name.The text was updated successfully, but these errors were encountered: