Skip to content

Commit 65fffcb

Browse files
authored
Correct OneOf deserialization (#1543)
* Generate stricter deserialization * Check if type attribute exists
1 parent dab636d commit 65fffcb

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

templates-v7/libraries/jersey3/oneof_model.mustache

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,10 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
120120
{{/isPrimitiveType}}
121121
if (attemptParsing) {
122122
// Checks if the unique type of the oneOf json matches any of the object TypeEnum values
123-
boolean typeMatch = Arrays.stream({{{dataType}}}.TypeEnum.values()).anyMatch((t) -> t.getValue().contains(tree.findValue("type").asText()));
123+
boolean typeMatch = false;
124+
if(tree.findValue("type") != null) {
125+
typeMatch = Arrays.stream({{{dataType}}}.TypeEnum.values()).anyMatch((t) -> t.getValue().equals(tree.findValue("type").asText()));
126+
}
124127

125128
if(typeMatch) {
126129
{{#isMap}}

0 commit comments

Comments
 (0)