From 935b69d232a8e9a8a253fb67c78641d95105a9e5 Mon Sep 17 00:00:00 2001 From: gcatanese Date: Mon, 18 Aug 2025 18:36:42 +0200 Subject: [PATCH 1/2] Generate stricter deserialization --- templates-v7/libraries/jersey3/oneof_model.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates-v7/libraries/jersey3/oneof_model.mustache b/templates-v7/libraries/jersey3/oneof_model.mustache index abd424638..eabc180f6 100644 --- a/templates-v7/libraries/jersey3/oneof_model.mustache +++ b/templates-v7/libraries/jersey3/oneof_model.mustache @@ -120,7 +120,7 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im {{/isPrimitiveType}} if (attemptParsing) { // Checks if the unique type of the oneOf json matches any of the object TypeEnum values - boolean typeMatch = Arrays.stream({{{dataType}}}.TypeEnum.values()).anyMatch((t) -> t.getValue().contains(tree.findValue("type").asText())); + boolean typeMatch = Arrays.stream({{{dataType}}}.TypeEnum.values()).anyMatch((t) -> t.getValue().equals(tree.findValue("type").asText())); if(typeMatch) { {{#isMap}} From a94098e30cd776a4cee030419ac6ee33f3ba062e Mon Sep 17 00:00:00 2001 From: gcatanese Date: Mon, 18 Aug 2025 18:48:25 +0200 Subject: [PATCH 2/2] Check if type attribute exists --- templates-v7/libraries/jersey3/oneof_model.mustache | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/templates-v7/libraries/jersey3/oneof_model.mustache b/templates-v7/libraries/jersey3/oneof_model.mustache index eabc180f6..87c894dc6 100644 --- a/templates-v7/libraries/jersey3/oneof_model.mustache +++ b/templates-v7/libraries/jersey3/oneof_model.mustache @@ -120,7 +120,10 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im {{/isPrimitiveType}} if (attemptParsing) { // Checks if the unique type of the oneOf json matches any of the object TypeEnum values - boolean typeMatch = Arrays.stream({{{dataType}}}.TypeEnum.values()).anyMatch((t) -> t.getValue().equals(tree.findValue("type").asText())); + boolean typeMatch = false; + if(tree.findValue("type") != null) { + typeMatch = Arrays.stream({{{dataType}}}.TypeEnum.values()).anyMatch((t) -> t.getValue().equals(tree.findValue("type").asText())); + } if(typeMatch) { {{#isMap}}