forked from loafle/openapi-generator-original
new -c/--config option for swagger-cli to specify json config file path
setting options passed in config file if those were allowed by lang specific CodegenConfig
This commit is contained in:
parent
c3055c7cc4
commit
c9c58cbe4c
@ -1,10 +1,13 @@
|
||||
package com.wordnik.swagger.codegen.cmd;
|
||||
|
||||
import com.wordnik.swagger.codegen.CliOption;
|
||||
import com.wordnik.swagger.codegen.ClientOptInput;
|
||||
import com.wordnik.swagger.codegen.ClientOpts;
|
||||
import com.wordnik.swagger.codegen.CodegenConfig;
|
||||
import com.wordnik.swagger.codegen.DefaultGenerator;
|
||||
import com.wordnik.swagger.models.Swagger;
|
||||
import config.Config;
|
||||
import config.ConfigParser;
|
||||
import io.airlift.airline.Command;
|
||||
import io.airlift.airline.Option;
|
||||
import io.swagger.parser.SwaggerParser;
|
||||
@ -57,6 +60,9 @@ public class Generate implements Runnable {
|
||||
@Option( name= {"-D"}, title = "system properties", description = "sets specified system properties in " +
|
||||
"the format of name=value,name=value")
|
||||
private String systemProperties;
|
||||
|
||||
@Option( name= {"-c", "--config"}, title = "configuration file", description = "path to json configuration file")
|
||||
private String configFile;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
@ -76,6 +82,17 @@ public class Generate implements Runnable {
|
||||
if (null != templateDir) {
|
||||
config.additionalProperties().put(TEMPLATE_DIR_PARAM, new File(templateDir).getAbsolutePath());
|
||||
}
|
||||
|
||||
if(null != configFile){
|
||||
Config genConfig = ConfigParser.read(configFile);
|
||||
if (null != genConfig) {
|
||||
for (CliOption langCliOption : config.cliOptions()) {
|
||||
if (genConfig.hasOption(langCliOption.getOpt())) {
|
||||
config.additionalProperties().put(langCliOption.getOpt(), genConfig.getOption(langCliOption.getOpt()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
input.setConfig(config);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user