Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Skip dont error when invalid jsonSchemaNode is found during traversal #44

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,11 @@ public static <T> List<T> traverseJsonSchemaWithFilteredCollector(final JsonNode
private static void traverseJsonSchemaInternal(final JsonNode jsonSchemaNode,
final List<FieldNameOrList> path,
final BiConsumer<JsonNode, List<FieldNameOrList>> consumer) {
if (!jsonSchemaNode.isObject()) {
throw new IllegalArgumentException(
String.format("json schema nodes should always be object nodes. path: %s actual: %s", path, jsonSchemaNode));
final boolean isTraversable = jsonSchemaNode.isObject();
if (!isTraversable) {
log.warn("json schema nodes should always be object nodes. path: {} actual: {}",
path, jsonSchemaNode);
return;
}
consumer.accept(jsonSchemaNode, path);
// if type is missing assume object. not official JsonSchema, but it seems to be a common
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ void testGetCatalogDiff() throws IOException {
StreamTransform.createRemoveStreamTransform(new StreamDescriptor().withName("accounts")),
StreamTransform.createUpdateStreamTransform(new StreamDescriptor().withName(USERS), new UpdateStreamTransform(Set.of(
FieldTransform.createAddFieldTransform(List.of("COD"), schema2.get(PROPERTIES).get("COD")),
FieldTransform.createAddFieldTransform(List.of("somePreviouslyInvalidField"), schema2.get(PROPERTIES).get("somePreviouslyInvalidField")),
FieldTransform.createRemoveFieldTransform(List.of("something2"), schema1.get(PROPERTIES).get("something2"), false),
FieldTransform.createRemoveFieldTransform(List.of("HKD"), schema1.get(PROPERTIES).get("HKD"), false),
FieldTransform.createUpdateFieldTransform(List.of(CAD), new UpdateFieldSchemaTransform(
Expand Down
1 change: 1 addition & 0 deletions protocol-models/src/test/resources/valid_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"DKK": { "type": ["null", "number"] },
"HUF": { "type": ["null", "number"] },
"文": { "type": ["null", "number"] },
"somePreviouslyInvalidField": [null, "integer"],
"something": {
"type": ["null", "object"],
"properties": {
Expand Down
3 changes: 3 additions & 0 deletions protocol-models/src/test/resources/valid_schema2.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
"DKK": { "type": ["null", "number"] },
"HUF": { "type": ["null", "number"] },
"文": { "type": ["null", "number"] },
"somePreviouslyInvalidField": {
"type": ["null", "integer"]
},
"something": {
"type": ["null", "object"],
"properties": {
Expand Down