Open marcuslange opened 5 years ago
Can you paste a simple example? I'd love to accommodate your needs.
@Getter
public class CreateUser {
@JsonProperty("first_name")
private final String firstName;
@JsonProperty("last_name")
private final String lastName;
@JsonProperty("email")
private final String email;
@JsonProperty("home_phone")
private final String homePhone;
@JsonProperty("cell_phone")
private final String cellPhone;
@JsonCreator
public CreateUser(@JsonProperty("first_name") String firstName,
@JsonProperty("last_name") String lastName,
@JsonProperty("email") String email,
@JsonProperty("home_phone") @Nullable String homePhone,
@JsonProperty("cell_phone") @Nullable String cellPhone) {
this.firstName = firstName;
this.lastName = lastName;
this.email = email;
this.homePhone = homePhone;
this.cellPhone = cellPhone;
}
}
I would expect for this you have HAL-FORM that is not marked readOnly and required false on the @Nullable fields.
That’s a tricky one as we‘d need access to Jackson’s mapping information, which properties it considers creators etc. and currently out property metamodel is entirely driven from a static context that doesn’t know anything about Jackson.
I’ll see whether we can abstract that away as it looks like the property inspection is usually triggered from within a context in which we have access to an AnnotationIntrospector
, so that we could wrap that into an implementation of an interface that all downstream components use to decide whether a property is a creator property.
@odrotbohm , I think java Record could be at least excluded from this behaviour by default. What do you think?
In cases where command style objects are used for PUT and POST we use immutable object with a @JsonCreator annotation. I think this is something that should be available in the affordances rendering vs just marking them readOnly.