Skip to content

Commit

Permalink
#16 Provide a single method to compare 2 OpenAPI instances
Browse files Browse the repository at this point in the history
  • Loading branch information
galovics committed Dec 15, 2018
1 parent edaf665 commit 4b0f93c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package io.redskap.swagger.brake.runner;

import java.util.Collection;

import io.redskap.swagger.brake.core.BreakChecker;
import io.redskap.swagger.brake.core.BreakingChange;
import io.redskap.swagger.brake.core.model.Specification;
import io.redskap.swagger.brake.core.model.transformer.Transformer;
import io.swagger.v3.oas.models.OpenAPI;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Component
@Slf4j
@RequiredArgsConstructor
public class Checker {
private final Transformer<OpenAPI, Specification> transformer;
private final BreakChecker breakChecker;

public Collection<BreakingChange> check(OpenAPI oldApi, OpenAPI newApi) {
log.info("Starting the check for breaking API changes");
Collection<BreakingChange> breakingChanges = breakChecker.check(transformer.transform(oldApi), transformer.transform(newApi));
log.info("Check is finished");
return breakingChanges;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

import java.util.Collection;

import io.redskap.swagger.brake.core.BreakChecker;
import io.redskap.swagger.brake.core.BreakingChange;
import io.redskap.swagger.brake.core.model.Specification;
import io.redskap.swagger.brake.core.model.transformer.Transformer;
import io.redskap.swagger.brake.report.ReporterFactory;
import io.redskap.swagger.brake.runner.download.ArtifactDownloaderHandler;
import io.redskap.swagger.brake.runner.openapi.OpenApiFactory;
Expand All @@ -19,11 +16,10 @@
@Component
@Slf4j
public class Runner {
private final Transformer<OpenAPI, Specification> transformer;
private final BreakChecker breakChecker;
private final ReporterFactory reporterFactory;
private final ArtifactDownloaderHandler artifactDownloaderHandler;
private final OpenApiFactory openApiFactory;
private final Checker checker;

public Collection<BreakingChange> run(Options options) {
artifactDownloaderHandler.handle(options);
Expand All @@ -40,9 +36,7 @@ public Collection<BreakingChange> run(Options options) {
OpenAPI oldApi = openApiFactory.fromFile(oldApiPath);
OpenAPI newApi = openApiFactory.fromFile(newApiPath);
log.info("Successfully loaded APIs");
log.info("Starting the check for breaking API changes");
Collection<BreakingChange> breakingChanges = breakChecker.check(transformer.transform(oldApi), transformer.transform(newApi));
log.info("Check is finished");
Collection<BreakingChange> breakingChanges = checker.check(oldApi, newApi);
reporterFactory.create(options).report(breakingChanges, options);
return breakingChanges;
}
Expand Down

0 comments on commit 4b0f93c

Please sign in to comment.