Skip to content

Commit

Permalink
[7.7] Remove ability to ingore files from spec validation (#56647) (#…
Browse files Browse the repository at this point in the history
…56689)

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 27, 2020
1 parent f98ef20 commit 43d6a8e
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 @@ -42,9 +40,7 @@
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
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 @@ -57,7 +53,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 @@ -80,16 +75,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 @@ -108,9 +93,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 43d6a8e

Please sign in to comment.