Skip to content

Commit

Permalink
DGS-9343 Allow removing enum in JSON Schema to be backward compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
rayokota committed Dec 5, 2023
1 parent 3e6f1c0 commit bafbad8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
Expand Up @@ -161,6 +161,16 @@ static void compare(final Context ctx, Schema original, Schema update) {
ctx.addDifferences(subctx.getDifferences());
return;
}
} else if (combinedSchema.getCriterion() == CombinedSchema.ALL_CRITERION) {
for (Schema subschema : combinedSchema.getSubschemas()) {
final Context subctx = ctx.getSubcontext();
compare(subctx, subschema, update);
if (subctx.isCompatible()) {
ctx.addDifferences(subctx.getDifferences());
ctx.addDifference(Type.PRODUCT_TYPE_NARROWED);
return;
}
}
}
}

Expand Down
16 changes: 16 additions & 0 deletions json-schema-provider/src/test/resources/diff-schema-examples.json
Expand Up @@ -349,6 +349,22 @@
],
"compatible": false
},
{
"description": "Detect removed enum ",
"original_schema": {
"type": "string",
"enum": [
"red"
]
},
"update_schema": {
"type": "string"
},
"changes": [
"PRODUCT_TYPE_NARROWED #/"
],
"compatible": true
},
{
"description": "Detect incompatible changes to enum schema",
"original_schema": {
Expand Down

0 comments on commit bafbad8

Please sign in to comment.