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)) {
|
||||
final String pattern;
|
||||
if (ModelUtils.isSet(schema)) {
|
||||
if (fullJavaUtil) {
|
||||
pattern = "new java.util.LinkedHashSet<%s>()";
|
||||
} else {
|
||||
pattern = "new LinkedHashSet<%s>()";
|
||||
}
|
||||
String mapInstantiationType = instantiationTypes().getOrDefault("set", "LinkedHashSet");
|
||||
pattern = "new " + mapInstantiationType + "<%s>()";
|
||||
} else {
|
||||
if (fullJavaUtil) {
|
||||
pattern = "new java.util.ArrayList<%s>()";
|
||||
} else {
|
||||
pattern = "new ArrayList<%s>()";
|
||||
}
|
||||
String arrInstantiationType = instantiationTypes().getOrDefault("array", "ArrayList");
|
||||
pattern = "new " + arrInstantiationType + "<%s>()";
|
||||
}
|
||||
|
||||
Schema<?> items = getSchemaItems((ArraySchema) schema);
|
||||
@ -840,12 +834,10 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
}
|
||||
return null;
|
||||
}
|
||||
final String pattern;
|
||||
if (fullJavaUtil) {
|
||||
pattern = "new java.util.HashMap<%s>()";
|
||||
} else {
|
||||
pattern = "new HashMap<%s>()";
|
||||
}
|
||||
|
||||
String mapInstantiationType = instantiationTypes().getOrDefault("map", "HashMap");
|
||||
final String pattern = "new " + mapInstantiationType + "<%s>()";
|
||||
|
||||
if (getAdditionalProperties(schema) == null) {
|
||||
return null;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user