forked from loafle/openapi-generator-original
undo some of the debugging changes I made
This commit is contained in:
@@ -4,11 +4,7 @@ import io.airlift.airline.Command;
|
||||
import io.airlift.airline.Option;
|
||||
import io.swagger.codegen.CliOption;
|
||||
import io.swagger.codegen.CodegenConfig;
|
||||
import io.swagger.codegen.cmd.utils.CodegenConfigLoader;
|
||||
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
import static java.util.ServiceLoader.load;
|
||||
import io.swagger.codegen.CodegenConfigLoader;
|
||||
|
||||
@Command(name = "config-help", description = "Config help for chosen lang")
|
||||
public class ConfigHelp implements Runnable {
|
||||
|
||||
@@ -8,9 +8,9 @@ import io.swagger.codegen.CliOption;
|
||||
import io.swagger.codegen.ClientOptInput;
|
||||
import io.swagger.codegen.ClientOpts;
|
||||
import io.swagger.codegen.CodegenConfig;
|
||||
import io.swagger.codegen.CodegenConfigLoader;
|
||||
import io.swagger.codegen.CodegenConstants;
|
||||
import io.swagger.codegen.DefaultGenerator;
|
||||
import io.swagger.codegen.cmd.utils.CodegenConfigLoader;
|
||||
import io.swagger.codegen.cmd.utils.OptionUtils;
|
||||
import io.swagger.models.Swagger;
|
||||
import io.swagger.parser.SwaggerParser;
|
||||
@@ -23,7 +23,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static java.util.ServiceLoader.load;
|
||||
import static org.apache.commons.lang3.StringUtils.isNotEmpty;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
package io.swagger.codegen.cmd.utils;
|
||||
|
||||
import io.swagger.codegen.CodegenConfig;
|
||||
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
import static java.util.ServiceLoader.load;
|
||||
|
||||
public class CodegenConfigLoader {
|
||||
/**
|
||||
* Tries to load config class with SPI first, then with class name directly from classpath
|
||||
*
|
||||
* @param name name of config, or full qualified class name in classpath
|
||||
* @return config class
|
||||
*/
|
||||
public static CodegenConfig forName(String name) {
|
||||
ServiceLoader<CodegenConfig> loader = load(CodegenConfig.class);
|
||||
for (CodegenConfig config : loader) {
|
||||
if (config.getName().equals(name)) {
|
||||
return config;
|
||||
}
|
||||
}
|
||||
|
||||
// else try to load directly
|
||||
try {
|
||||
return (CodegenConfig) Class.forName(name).newInstance();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Can't load config class with name ".concat(name), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user