Add all required parameters as default constructor parameters #1294

This commit is contained in:
Johannes Fiala
2015-12-06 10:37:06 +01:00
parent 1a8a03ee52
commit 8fd6b604d3
4 changed files with 29 additions and 8 deletions

View File

@@ -13,6 +13,13 @@ public class CodegenModel {
public String unescapedDescription;
public String defaultValue;
public List<CodegenProperty> vars = new ArrayList<CodegenProperty>();
// list of all required parameters
public Set<String> mandatory = new HashSet<String>();
// TODO: temporary solution to get a delimited list of default constructor parameters, should be replaced if there is a better way of injecting the mandatory parameters into the mustache templates
public String mandatoryParams;
public Set<String> imports = new HashSet<String>();
public Boolean hasVars, emptyVars, hasMoreModels, hasEnums;
public ExternalDocs externalDocs;

View File

@@ -1881,6 +1881,10 @@ public class DefaultCodegen {
m.vars.add(cp);
}
}
m.mandatory = mandatory;
m.mandatoryParams = StringUtils.join(mandatory, ", ");
} else {
m.emptyVars = true;
m.hasVars = false;