You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Using the java generator, with okhttp-gson (the default), the model classes raise exceptions whenever the API returns a property the models do not know about. It does not seem that (at least) some of the other library generators share this problem, only based on my own brief inspection of the resulting code
Describe the solution you'd like
I would like for the models to tolerate properties that weren't known at the time of generation
Describe alternatives you've considered
Vending my own template, okhttp-gson/pojo.mustache
Additional context
The code I wish to remove looks like this:
publicstaticvoidvalidateJsonElement(JsonElementjsonElement) throwsIOException {
// ...Set<Map.Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fieldsfor (Map.Entry<String, JsonElement> entry : entries) {
if (!Action.openapiFields.contains(entry.getKey())) {
thrownewIllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Action` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
}
}
// ...
}
The code I want would exclude that block or assign entries to Collections.emptySet()
+1. This affects the official Kubernetes Java client (kubernetes-client/java), which is
generated with okhttp-gson. The Kubernetes API adds optional fields in minor releases, so with
these models a cluster newer than the client fails reads, e.g. on EKS 1.37:
The field runningInUserNamespace in the JSON string is not defined in the V1NodeSystemInfo properties
Would you accept a PR that adds a generator option, e.g. failOnUnknownProperties, defaulting to
the current behaviour? It would skip the "check to see if the JSON string contains additional
fields" loop in okhttp-gson/pojo.mustache, and leave the required-field and type checks as they
are. That would let clients like kubernetes-client keep their other validation while tolerating
schema growth.
Activity
sar009 commentedon Oct 12, 2026
+1. This affects the official Kubernetes Java client (kubernetes-client/java), which is
generated with okhttp-gson. The Kubernetes API adds optional fields in minor releases, so with
these models a cluster newer than the client fails reads, e.g. on EKS 1.37:
Tracked downstream in kubernetes-client/java#4941 (earlier: kubernetes-client/java#3428, kubernetes-client/java#3980, kubernetes-client/java#4809).
Would you accept a PR that adds a generator option, e.g.
failOnUnknownProperties, defaulting tothe current behaviour? It would skip the "check to see if the JSON string contains additional
fields" loop in
okhttp-gson/pojo.mustache, and leave the required-field and type checks as theyare. That would let clients like kubernetes-client keep their other validation while tolerating
schema growth.