Skip to content

Updated additional contract validation error to include ref #90

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
11 changes: 10 additions & 1 deletion src/main/java/io/vertx/openapi/contract/OpenAPIContract.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,16 @@ static Future<OpenAPIContract> from(Vertx vertx, JsonObject unresolvedContract,
// method and reused below.
JsonObject file = additionalContractFiles.get(ref);
Future<?> validationFuture = version.validateAdditionalContractFile(vertx, repository, file)
.compose(v -> vertx.executeBlocking(() -> repository.dereference(ref, JsonSchema.of(ref, file))));
.compose(v -> vertx.executeBlocking(() -> repository.dereference(ref, JsonSchema.of(ref, file))))
.transform(ar -> {
if (ar.failed()) {
return Future.failedFuture(
createInvalidContract("Failed to validate additional contract file: " + ref, ar.cause())
);
} else {
return (Future<?>) ar;
}
});

validationFutures.add(validationFuture);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,10 @@ void testMalformedJsonSchemaProvidedAsAdditionalSpecFiles(Vertx vertx, VertxTest
assertTrue(handler.failed());
assertThat(handler.cause()).isInstanceOf(OpenAPIContractException.class);
assertThat(handler.cause()).hasMessageThat()
.isEqualTo("The passed OpenAPI contract is invalid: Found issue in specification for reference:" +
" -1 is less than 0");
.isEqualTo("The passed OpenAPI contract is invalid: Failed to validate additional contract file: " +
"https://example.com/petstore");
assertThat(handler.cause().getCause()).hasMessageThat()
.isEqualTo("-1 is less than 0");
testContext.completeNow();
}));
}
Expand Down