forked from loafle/openapi-generator-original
[bug][Java] Honor instantiationMap for default values for array, map, set (#4982)
Co-authored-by: Jim Schubert <james.schubert@gmail.com>
This commit is contained in:
parent
9778d970ac
commit
5f3d974a08
@ -807,17 +807,11 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
|||||||
if (ModelUtils.isArraySchema(schema)) {
|
if (ModelUtils.isArraySchema(schema)) {
|
||||||
final String pattern;
|
final String pattern;
|
||||||
if (ModelUtils.isSet(schema)) {
|
if (ModelUtils.isSet(schema)) {
|
||||||
if (fullJavaUtil) {
|
String mapInstantiationType = instantiationTypes().getOrDefault("set", "LinkedHashSet");
|
||||||
pattern = "new java.util.LinkedHashSet<%s>()";
|
pattern = "new " + mapInstantiationType + "<%s>()";
|
||||||
} else {
|
|
||||||
pattern = "new LinkedHashSet<%s>()";
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (fullJavaUtil) {
|
String arrInstantiationType = instantiationTypes().getOrDefault("array", "ArrayList");
|
||||||
pattern = "new java.util.ArrayList<%s>()";
|
pattern = "new " + arrInstantiationType + "<%s>()";
|
||||||
} else {
|
|
||||||
pattern = "new ArrayList<%s>()";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Schema<?> items = getSchemaItems((ArraySchema) schema);
|
Schema<?> items = getSchemaItems((ArraySchema) schema);
|
||||||
@ -840,12 +834,10 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
final String pattern;
|
|
||||||
if (fullJavaUtil) {
|
String mapInstantiationType = instantiationTypes().getOrDefault("map", "HashMap");
|
||||||
pattern = "new java.util.HashMap<%s>()";
|
final String pattern = "new " + mapInstantiationType + "<%s>()";
|
||||||
} else {
|
|
||||||
pattern = "new HashMap<%s>()";
|
|
||||||
}
|
|
||||||
if (getAdditionalProperties(schema) == null) {
|
if (getAdditionalProperties(schema) == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user