Merge branch 'Rogercf-support-to-array-of-enums' into develop_2.0

This commit is contained in:
Tony Tam 2015-08-23 17:22:44 -07:00
commit 9531e1ae59
3 changed files with 28 additions and 20 deletions

View File

@ -34,6 +34,7 @@ public class CodegenProperty {
public boolean isEnum; public boolean isEnum;
public List<String> _enum; public List<String> _enum;
public Map<String, Object> allowableValues; public Map<String, Object> allowableValues;
public CodegenProperty items;
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
@ -136,6 +137,4 @@ public class CodegenProperty {
} }
return true; return true;
} }
} }

View File

@ -676,7 +676,7 @@ public class DefaultCodegen {
property.isContainer = true; property.isContainer = true;
property.containerType = "array"; property.containerType = "array";
ArrayProperty ap = (ArrayProperty) p; ArrayProperty ap = (ArrayProperty) p;
CodegenProperty cp = fromProperty("inner", ap.getItems()); CodegenProperty cp = fromProperty(property.name, ap.getItems());
if (cp == null) { if (cp == null) {
LOGGER.warn("skipping invalid property " + Json.pretty(p)); LOGGER.warn("skipping invalid property " + Json.pretty(p));
} else { } else {
@ -686,6 +686,12 @@ public class DefaultCodegen {
} else { } else {
property.isPrimitiveType = true; property.isPrimitiveType = true;
} }
property.items = cp;
if (property.items.isEnum) {
property.datatypeWithEnum = property.datatypeWithEnum.replace(property.items.baseType,
property.items.datatypeWithEnum);
property.defaultValue = property.defaultValue.replace(property.items.baseType, property.items.datatypeWithEnum);
}
} }
} else if (p instanceof MapProperty) { } else if (p instanceof MapProperty) {
property.isContainer = true; property.isContainer = true;

View File

@ -18,11 +18,14 @@ import com.fasterxml.jackson.annotation.JsonProperty;
{{>generatedAnnotation}} {{>generatedAnnotation}}
public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#serializableModel}}implements Serializable{{/serializableModel}} { public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#serializableModel}}implements Serializable{{/serializableModel}} {
{{#vars}}{{#isEnum}} {{#vars}}{{#isEnum}}
public enum {{datatypeWithEnum}} {
{{#allowableValues}}{{#values}} {{.}}, {{/values}}{{/allowableValues}}
};{{/isEnum}}{{#items.isEnum}}{{#items}}
public enum {{datatypeWithEnum}} { public enum {{datatypeWithEnum}} {
{{#allowableValues}}{{#values}} {{.}}, {{/values}}{{/allowableValues}} {{#allowableValues}}{{#values}} {{.}}, {{/values}}{{/allowableValues}}
}; };
private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};{{/isEnum}}{{^isEnum}} {{/items}}{{/items.isEnum}}
private {{{datatype}}} {{name}} = {{{defaultValue}}};{{/isEnum}}{{/vars}} private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};{{/vars}}
{{#vars}} {{#vars}}
/**{{#description}} /**{{#description}}