Skip to content

Commit

Permalink
Remove ability to ingore files from spec validation (#56647)
Browse files Browse the repository at this point in the history
An ignore parameter was originally added to the ValidateJsonAgainstSchemaTask
to allow the build to pass for REST specs that did not properly validate
against the schema.

Since the introduction of this task, all schemas that did not validate have
been fixed to now validate properly.

This commit removes the ability to ignore specific files for validation. This
allows any consumers the assurance that all REST specs validate against the schema.
  • Loading branch information
jakelandis authored May 13, 2020
1 parent 34dd9d1 commit f5f0343
Showing 1 changed file with 1 addition and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@
import org.gradle.api.DefaultTask;
import org.gradle.api.UncheckedIOException;
import org.gradle.api.file.FileCollection;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.InputFile;
import org.gradle.api.tasks.InputFiles;
import org.gradle.api.tasks.Optional;
import org.gradle.api.tasks.OutputFile;
import org.gradle.api.tasks.TaskAction;
import org.gradle.work.ChangeType;
Expand All @@ -44,9 +42,7 @@
import java.io.PrintWriter;
import java.nio.file.Files;
import java.nio.file.StandardOpenOption;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
Expand All @@ -59,7 +55,6 @@
public class ValidateJsonAgainstSchemaTask extends DefaultTask {

private final ObjectMapper mapper = new ObjectMapper();
private Set<String> ignore = new HashSet<>();
private File jsonSchema;
private FileCollection inputFiles;

Expand All @@ -82,16 +77,6 @@ public void setJsonSchema(File jsonSchema) {
this.jsonSchema = jsonSchema;
}

@Input
@Optional
public Set<String> getIgnore() {
return ignore;
}

public void ignore(String... ignore) {
this.ignore.addAll(Arrays.asList(ignore));
}

@OutputFile
public File getReport() {
return new File(getProject().getBuildDir(), "reports/validateJson.txt");
Expand All @@ -110,9 +95,7 @@ public void validate(InputChanges inputChanges) throws IOException {
.filter(f -> f.getChangeType() != ChangeType.REMOVED)
.forEach(fileChange -> {
File file = fileChange.getFile();
if (ignore.contains(file.getName())) {
getLogger().debug("Ignoring file [{}] due to configuration", file.getName());
} else if (file.isDirectory() == false) {
if (file.isDirectory() == false) {
// validate all files and hold on to errors for a complete report if there are failures
getLogger().debug("Validating JSON [{}]", file.getName());
try {
Expand Down

0 comments on commit f5f0343

Please sign in to comment.