forked from loafle/openapi-generator-original
Fixes issue where only some instances of List or Map were replaced with Built equivalents (#4645)
If there was a type that had a nested type of List or Map, e.g. `Map<String, List<String>>` only the outer types would be replaced with the Built variants, causing issues when running the builder.
This commit is contained in:
parent
c0994c479d
commit
e90fa5c4df
@ -285,37 +285,26 @@ public class DartDioClientCodegen extends DartClientCodegen {
|
||||
property.isNullable = true;
|
||||
}
|
||||
|
||||
if (property.isListContainer) {
|
||||
//Updates any List properties on a model to a BuiltList. This happens in post processing rather
|
||||
//than type mapping as we only want this to apply to models, not every other class.
|
||||
if ("List".equals(property.baseType)) {
|
||||
property.setDatatype(
|
||||
property.dataType.replaceAll(property.baseType, "BuiltList"));
|
||||
property.setBaseType("BuiltList");
|
||||
model.imports.add("BuiltList");
|
||||
if ("Object".equals(property.items.baseType)) {
|
||||
property.setDatatype(
|
||||
property.dataType.replaceAll("Object", "JsonObject"));
|
||||
property.items.setDatatype("JsonObject");
|
||||
model.imports.add("JsonObject");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (property.isMapContainer) {
|
||||
//Updates any List properties on a model to a BuiltList. This happens in post processing rather
|
||||
//than type mapping as we only want this to apply to models, not every other class.
|
||||
if ("Map".equals(property.baseType)) {
|
||||
property.setDatatype(property.dataType.replaceAll(property.baseType, "BuiltMap"));
|
||||
property.setBaseType("BuiltMap");
|
||||
model.imports.add("BuiltMap");
|
||||
if ("Object".equals(property.items.baseType)) {
|
||||
property.setDatatype(property.dataType.replaceAll("Object", "JsonObject"));
|
||||
property.items.setDatatype("JsonObject");
|
||||
model.imports.add("JsonObject");
|
||||
}
|
||||
}
|
||||
}
|
||||
property.setDatatype(property.getDataType()
|
||||
.replaceAll("\\bList\\b", "BuiltList")
|
||||
.replaceAll("\\bMap\\b", "BuiltMap")
|
||||
.replaceAll("\\bObject\\b", "JsonObject")
|
||||
);
|
||||
property.setBaseType(property.getBaseType()
|
||||
.replaceAll("\\bList\\b", "BuiltList")
|
||||
.replaceAll("\\bMap\\b", "BuiltMap")
|
||||
.replaceAll("\\bObject\\b", "JsonObject")
|
||||
);
|
||||
|
||||
if (property.dataType.contains("BuiltList")) {
|
||||
model.imports.add("BuiltList");
|
||||
}
|
||||
if (property.dataType.contains("BuiltMap")) {
|
||||
model.imports.add("BuiltMap");
|
||||
}
|
||||
if (property.dataType.contains("JsonObject")) {
|
||||
model.imports.add("JsonObject");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -10,8 +10,6 @@ abstract class {{classname}} implements Built<{{classname}}, {{classname}}Builde
|
||||
{{#isNullable}}
|
||||
@nullable
|
||||
{{/isNullable}}
|
||||
|
||||
{{#description}}/* {{{description}}} */{{/description}}
|
||||
@BuiltValueField(wireName: '{{baseName}}')
|
||||
{{{dataType}}} get {{name}};
|
||||
{{#allowableValues}}
|
||||
|
Loading…
x
Reference in New Issue
Block a user