Skip to content
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

Add canonical setter for additionalProperties #1589

Open
salvalcantara opened this issue Feb 23, 2024 · 0 comments
Open

Add canonical setter for additionalProperties #1589

salvalcantara opened this issue Feb 23, 2024 · 0 comments

Comments

@salvalcantara
Copy link

salvalcantara commented Feb 23, 2024

Problem Statement

Currently, for objects with "additionalProperties": true, the following code gets generated:

private Map<String, Object> additionalProperties = new LinkedHashMap<~>();

@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() { /* ... */ }

@JsonAnySetter
public void setAdditionalProperty(String name, Object value) { /* ... */ }

For state schema evolution, some stream processing frameworks like Flink require POJOs to follow the Java beans naming conventions for getters and setters, e.g., see:

For the case at hand this means that, to avoid trouble, the following setter should be generated:

public void setAdditionalProperties(Map<String, Object> properties) { /* ... */ }

Proposed Solution

It that makes sense in general, by default we could add the missing/canonical setter setAdditionalProperties (acting on the entire set of properties) alongside the current one setAdditionalProperty (acting on individual properties).

Alternatively users could manage that themselves by either providing a custom factory for the additionalProperties or by simply ignoring any unknown properties (via @JsonIgnore).

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

No branches or pull requests

1 participant