Skip to content

Commit

Permalink
fix recursive lookup of tm:refs in WoT model extension resolving
Browse files Browse the repository at this point in the history
(cherry picked from commit 757c1a0)
  • Loading branch information
thjaeckle committed Apr 8, 2024
1 parent c21f377 commit c811b24
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
Expand Up @@ -147,6 +147,14 @@ private CompletionStage<JsonValue> resolveRefs(final JsonObject objectWithTmRef,
.orElseGet(() -> CompletableFuture.completedFuture(null))
, executor
)
.thenCompose(refObject -> {
if (refObject.contains(TM_REF)) {
return resolveRefs(refObject, dittoHeaders) // recurse!
.thenApply(JsonValue::asObject);
} else {
return potentiallyResolveRefs(refObject, dittoHeaders); // recurse!
}
})
.thenApply(refObject ->
JsonFactory.mergeJsonValues(objectWithTmRef.remove(TM_REF), refObject).asObject()
);
Expand Down
Expand Up @@ -82,7 +82,8 @@ static SecurityScheme fromJson(final CharSequence securitySchemeName, final Json
return AdditionalSecurityScheme.fromJson(schemeName, jsonObject);
}
})
.orElseThrow(() -> new IllegalArgumentException("Could not create SingleDataSchema"));
.orElseThrow(() -> new IllegalArgumentException("Could not create SecurityScheme - " +
"json field <" + SecuritySchemeJsonFields.SCHEME.getPointer() + "> was missing or unknown"));
}

static NoSecurityScheme.Builder newNoSecurityBuilder(final CharSequence securitySchemeName) {
Expand Down
Expand Up @@ -68,7 +68,8 @@ static SingleDataSchema fromJson(final JsonObject jsonObject) {
throw new IllegalArgumentException("Unsupported dataSchema-type: " + type);
}
})
.orElseThrow(() -> new IllegalArgumentException("Could not create SingleDataSchema"));
.orElseThrow(() -> new IllegalArgumentException("Could not create SingleDataSchema - " +
"json field <" + DataSchemaJsonFields.TYPE.getPointer() + "> was missing or unknown"));
}

static BooleanSchema.Builder newBooleanSchemaBuilder() {
Expand Down

0 comments on commit c811b24

Please sign in to comment.