Skip to content

Improve logging when there is no validator found for a path #40

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

Merged
merged 3 commits into from
Sep 22, 2023
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 @@ -12,7 +12,7 @@
import org.apache.commons.lang3.tuple.Pair;

public class MultipleSpecOpenApiInteractionValidatorWrapper implements OpenApiInteractionValidatorWrapper {
public static final String MESSAGE_KEY_VALIDATOR_FOUND = "zopenapi-validator-java.noValidatorFound";
public static final String MESSAGE_KEY_NO_VALIDATOR_FOUND = "openapi-validator-java.noValidatorFound";
private final List<Pair<Pattern, OpenApiInteractionValidatorWrapper>> validators;

public MultipleSpecOpenApiInteractionValidatorWrapper(
Expand Down Expand Up @@ -49,8 +49,8 @@ private Optional<OpenApiInteractionValidatorWrapper> getValidatorForPath(String

private static SimpleMessage buildNoValidatorFoundMessage(String path) {
return new SimpleMessage(
MESSAGE_KEY_VALIDATOR_FOUND,
"No validator found for path: " + path,
MESSAGE_KEY_NO_VALIDATOR_FOUND,
"ValidatorConfiguration has no spec file matching path: " + path,
ValidationReport.Level.WARN
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.getyourguide.openapi.validation.core.validator;

import static com.getyourguide.openapi.validation.core.validator.MultipleSpecOpenApiInteractionValidatorWrapper.MESSAGE_KEY_VALIDATOR_FOUND;
import static com.getyourguide.openapi.validation.core.validator.MultipleSpecOpenApiInteractionValidatorWrapper.MESSAGE_KEY_NO_VALIDATOR_FOUND;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
Expand Down Expand Up @@ -52,8 +52,8 @@ public void testReturnsViolationWhenNoMatchingValidatorFound() {
var messages = report.getMessages();
assertEquals(1, messages.size());
var message = messages.get(0);
assertEquals(MESSAGE_KEY_VALIDATOR_FOUND, message.getKey());
assertEquals("No validator found for path: /123", message.getMessage());
assertEquals(MESSAGE_KEY_NO_VALIDATOR_FOUND, message.getKey());
assertEquals("ValidatorConfiguration has no spec file matching path: /123", message.getMessage());
}

private static MockValidatorResult mockValidator() {
Expand Down