|
30 | 30 |
|
31 | 31 | import java.io.File;
|
32 | 32 | import java.util.HashMap;
|
| 33 | +import java.util.HashSet; |
33 | 34 | import java.util.Map;
|
| 35 | +import java.util.Set; |
34 | 36 |
|
35 | 37 | import static io.swagger.codegen.plugin.AdditionalParams.*;
|
36 | 38 |
|
@@ -152,17 +154,20 @@ public void execute() throws MojoExecutionException {
|
152 | 154 | if (null != invokerPackage) {
|
153 | 155 | config.additionalProperties().put(INVOKER_PACKAGE_PARAM, invokerPackage);
|
154 | 156 | }
|
155 |
| - |
| 157 | + |
| 158 | + Set<String> definedOptions = new HashSet<String>(); |
| 159 | + for (CliOption langCliOption : config.cliOptions()) { |
| 160 | + definedOptions.add(langCliOption.getOpt()); |
| 161 | + } |
| 162 | + |
156 | 163 | if (configOptions != null) {
|
157 |
| - for(Map.Entry<?, ?> configEntry : configOptions.entrySet()) { |
158 |
| - config.additionalProperties().put(configEntry.getKey().toString(), configEntry.getValue()); |
159 |
| - } |
| 164 | + addAdditionalProperties(config, definedOptions, configOptions); |
160 | 165 | }
|
161 | 166 |
|
162 | 167 | if (null != configurationFile) {
|
163 | 168 | Config genConfig = ConfigParser.read(configurationFile);
|
164 | 169 | if (null != genConfig) {
|
165 |
| - config.additionalProperties().putAll(genConfig.getOptions()); |
| 170 | + addAdditionalProperties(config, definedOptions, genConfig.getOptions()); |
166 | 171 | } else {
|
167 | 172 | throw new RuntimeException("Unable to read configuration file");
|
168 | 173 | }
|
@@ -193,4 +198,13 @@ public void execute() throws MojoExecutionException {
|
193 | 198 | project.addCompileSourceRoot(output.toString());
|
194 | 199 | }
|
195 | 200 | }
|
| 201 | + |
| 202 | + private void addAdditionalProperties(CodegenConfig config, Set<String> definedOptions, Map<?,?> configOptions) { |
| 203 | + for(Map.Entry<?, ?> configEntry : configOptions.entrySet()) { |
| 204 | + config.additionalProperties().put(configEntry.getKey().toString(), configEntry.getValue()); |
| 205 | + if(!definedOptions.contains(configEntry.getKey())) { |
| 206 | + getLog().warn("Additional property: " + configEntry.getKey() + " is not defined for this language."); |
| 207 | + } |
| 208 | + } |
| 209 | + } |
196 | 210 | }
|
0 commit comments