added import when description is present

This commit is contained in:
Tony Tam 2016-03-09 00:03:06 -08:00
parent 998087d662
commit 8da197ced7

View File

@ -525,7 +525,9 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
@Override @Override
public CodegenModel fromModel(String name, Model model, Map<String, Model> allDefinitions) { public CodegenModel fromModel(String name, Model model, Map<String, Model> allDefinitions) {
CodegenModel codegenModel = super.fromModel(name, model, allDefinitions); CodegenModel codegenModel = super.fromModel(name, model, allDefinitions);
if(codegenModel.description != null) {
codegenModel.imports.add("ApiModel");
}
if (allDefinitions != null && codegenModel != null && codegenModel.parentSchema != null && codegenModel.hasEnums) { if (allDefinitions != null && codegenModel != null && codegenModel.parentSchema != null && codegenModel.hasEnums) {
final Model parentModel = allDefinitions.get(codegenModel.parentSchema); final Model parentModel = allDefinitions.get(codegenModel.parentSchema);
final CodegenModel parentCodegenModel = super.fromModel(codegenModel.parent, parentModel); final CodegenModel parentCodegenModel = super.fromModel(codegenModel.parent, parentModel);
@ -584,6 +586,7 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
for (Object _mo : models) { for (Object _mo : models) {
Map<String, Object> mo = (Map<String, Object>) _mo; Map<String, Object> mo = (Map<String, Object>) _mo;
CodegenModel cm = (CodegenModel) mo.get("model"); CodegenModel cm = (CodegenModel) mo.get("model");
for (CodegenProperty var : cm.vars) { for (CodegenProperty var : cm.vars) {
Map<String, Object> allowableValues = var.allowableValues; Map<String, Object> allowableValues = var.allowableValues;