Merge pull request #2691 from wing328/add_required_optional_vars

Add requiredVars and optionalVars for codegen model
This commit is contained in:
wing328
2016-04-24 21:21:34 +08:00
5 changed files with 15 additions and 4 deletions

View File

@@ -18,6 +18,8 @@ public class CodegenModel {
public String discriminator;
public String defaultValue;
public List<CodegenProperty> vars = new ArrayList<CodegenProperty>();
public List<CodegenProperty> requiredVars = new ArrayList<CodegenProperty>(); // a list of required properties
public List<CodegenProperty> optionalVars = new ArrayList<CodegenProperty>(); // a list of optional properties
public List<CodegenProperty> allVars;
public List<String> allowableValues;

View File

@@ -2307,6 +2307,12 @@ public class DefaultCodegen {
addImport(m, cp.baseType);
addImport(m, cp.complexType);
vars.add(cp);
if (Boolean.TRUE.equals(cp.required)) { // if required, add to the list "requiredVars"
m.requiredVars.add(cp);
} else { // else add to the list "optionalVars" for optional property
m.optionalVars.add(cp);
}
}
}
}