[dart-dio] Add missing imports for container parameters (#8355)

* also remove redundant needToImport check
This commit is contained in:
Peter Leibiger 2021-01-07 15:27:27 +01:00 committed by GitHub
parent f5b2bb5057
commit 3b6c2b2342
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View File

@ -558,6 +558,18 @@ public class DartClientCodegen extends DefaultCodegen {
}
}
}
for (CodegenParameter p : op.allParams) {
if (p.isContainer) {
final String type = p.isArray ? "array" : "map";
if (typeMapping().containsKey(type)) {
final String value = typeMapping().get(type);
// Also add container imports for parameters.
if (needToImport(value)) {
op.imports.add(value);
}
}
}
}
return op;
}

View File

@ -327,7 +327,7 @@ public class DartDioClientCodegen extends DartClientCodegen {
Set<String> imports = new HashSet<>();
for (String item : op.imports) {
if (needToImport(item)) {
if (importMapping().containsKey(item) && needToImport(item)) {
if (importMapping().containsKey(item)) {
fullImports.add(importMapping().get(item));
} else {
imports.add(underscore(item));