Generate @JsonAnyGetter for every generated class with openapi-generator-maven-plugin

41 Views Asked by At

I would like to have something like this in every generated DTO class:

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

@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
    return this.additionalProperties;
}

@JsonAnySetter
public void setAdditionalProperty(String name, Object value) {
    this.additionalProperties.put(name, value);
}

and no errors on unknown properties but storing them in the map. I only found disallowAdditionalPropertiesIfNotPresent which does not have any effect for me.

Some issues on GitHub sound like it is not yet possible: https://github.com/OpenAPITools/openapi-generator/issues/16172

Is there any way to achieve this? I use the maven plugin openapi-generator-maven-plugin with version 6.2.1 and RestEasy with Jackson.

0

There are 0 best solutions below