forked from loafle/openapi-generator-original
Added warnings when the additionalProperties are not defined in the
cliOptions of a language.
This commit is contained in:
parent
68c6954615
commit
f13b4deb2e
@ -30,7 +30,9 @@ import org.apache.maven.project.MavenProject;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import static io.swagger.codegen.plugin.AdditionalParams.*;
|
import static io.swagger.codegen.plugin.AdditionalParams.*;
|
||||||
|
|
||||||
@ -153,16 +155,19 @@ public class CodeGenMojo extends AbstractMojo {
|
|||||||
config.additionalProperties().put(INVOKER_PACKAGE_PARAM, invokerPackage);
|
config.additionalProperties().put(INVOKER_PACKAGE_PARAM, invokerPackage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Set<String> definedOptions = new HashSet<String>();
|
||||||
|
for (CliOption langCliOption : config.cliOptions()) {
|
||||||
|
definedOptions.add(langCliOption.getOpt());
|
||||||
|
}
|
||||||
|
|
||||||
if (configOptions != null) {
|
if (configOptions != null) {
|
||||||
for(Map.Entry<?, ?> configEntry : configOptions.entrySet()) {
|
addAdditionalProperties(config, definedOptions, configOptions);
|
||||||
config.additionalProperties().put(configEntry.getKey().toString(), configEntry.getValue());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null != configurationFile) {
|
if (null != configurationFile) {
|
||||||
Config genConfig = ConfigParser.read(configurationFile);
|
Config genConfig = ConfigParser.read(configurationFile);
|
||||||
if (null != genConfig) {
|
if (null != genConfig) {
|
||||||
config.additionalProperties().putAll(genConfig.getOptions());
|
addAdditionalProperties(config, definedOptions, genConfig.getOptions());
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException("Unable to read configuration file");
|
throw new RuntimeException("Unable to read configuration file");
|
||||||
}
|
}
|
||||||
@ -193,4 +198,13 @@ public class CodeGenMojo extends AbstractMojo {
|
|||||||
project.addCompileSourceRoot(output.toString());
|
project.addCompileSourceRoot(output.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addAdditionalProperties(CodegenConfig config, Set<String> definedOptions, Map<?,?> configOptions) {
|
||||||
|
for(Map.Entry<?, ?> configEntry : configOptions.entrySet()) {
|
||||||
|
config.additionalProperties().put(configEntry.getKey().toString(), configEntry.getValue());
|
||||||
|
if(!definedOptions.contains(configEntry.getKey())) {
|
||||||
|
getLog().warn("Additional property: " + configEntry.getKey() + " is not defined for this language.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user