forked from loafle/openapi-generator-original
Merge pull request #2691 from wing328/add_required_optional_vars
Add requiredVars and optionalVars for codegen model
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user