Closed dalewking closed 5 years ago
Done. Please check if it suits your use-case. :-)
Was looking for a static method to call that hid all the dependency injection from me the way Stater.start does. What you have here requires me to still instantiate the Context to get the Checker.
I mean if I provide a static method which does all the configuration in advance, it's undermining the modularity of swagger-brake. Now you want to use only a a single component of Swagger Brake so you have to do the configuration for sure.
Is it really a big issue that you have to do the configuration?
I don't see how it is undermining modularity. You provide that with Starter.start. All I am asking for is Starter to look like this:
public class Starter {
private static BeanFactory getBeanFactory() {
return new AnnotationConfigApplicationContext(RunnerConfiguration.class, ReporterConfiguration.class,
MavenConfiguration.class, CoreConfiguration.class);
}
public static Collection<BreakingChange> start(Options options) {
return getBeanFactory().getBean(Runner.class).run(options);
}
public static Collection<BreakingChange> check(OpenAPI oldApi, OpenAPI newApi) {
return getBeanFactory().getBean(Checker.class).check(oldApi, newApi);
}
}
You got it @dalewking. :-)
Since you are splitting out the CLI from the core library, was hoping you could provide a simple entry point that takes in 2 OpenAPI instances and returns the list of breaking changes.
Here is the code I am currently doing on my side, but you could do it much easier in the library:
Should be easy if you extract this expression on Runner to a new method called check:
Extract everything before
.run(options)
in Starter.start to a getRunner method. Then add this method to Starter: