mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-03 22:20:56 +00:00
Merge branch 'Rogercf-support-to-array-of-enums' into develop_2.0
This commit is contained in:
commit
9531e1ae59
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -672,22 +672,28 @@ public class DefaultCodegen {
|
|||||||
|
|
||||||
property.baseType = getSwaggerType(p);
|
property.baseType = getSwaggerType(p);
|
||||||
|
|
||||||
if (p instanceof ArrayProperty) {
|
if (p instanceof ArrayProperty) {
|
||||||
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 {
|
||||||
property.baseType = getSwaggerType(p);
|
property.baseType = getSwaggerType(p);
|
||||||
if (!languageSpecificPrimitives.contains(cp.baseType)) {
|
if (!languageSpecificPrimitives.contains(cp.baseType)) {
|
||||||
property.complexType = cp.baseType;
|
property.complexType = cp.baseType;
|
||||||
} else {
|
} else {
|
||||||
property.isPrimitiveType = true;
|
property.isPrimitiveType = true;
|
||||||
}
|
}
|
||||||
}
|
property.items = cp;
|
||||||
} else if (p instanceof MapProperty) {
|
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) {
|
||||||
property.isContainer = true;
|
property.isContainer = true;
|
||||||
property.containerType = "map";
|
property.containerType = "map";
|
||||||
MapProperty ap = (MapProperty) p;
|
MapProperty ap = (MapProperty) p;
|
||||||
|
@ -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}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user