Skip to content

Commit

Permalink
[dart][dio] Respect import-mappings parameter
Browse files Browse the repository at this point in the history
* first check import mappings before defaulting to model import
* respect primitive types when generating serializes, these can still be models if passed via generator args
  • Loading branch information
kuhnroyal committed Oct 10, 2021
1 parent efa032a commit 4b16589
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,8 @@ private Set<String> rewriteImports(Set<String> originalImports, boolean isModel)
continue;
}
resultImports.add(i);
} else if (importMapping().containsKey(modelImport)) {
resultImports.add(importMapping().get(modelImport));
} else {
resultImports.add("package:" + pubName + "/src/model/" + underscore(modelImport) + ".dart");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,13 @@ class _${{classname}}Serializer implements StructuredSerializer<{{classname}}> {
result.{{{name}}}.replace(valueDes);
{{/isContainer}}
{{#isModel}}
{{#isPrimitiveType}}
{{! These are models that have nee manually marked as primitve via generator param. }}
result.{{{name}}} = valueDes;
{{/isPrimitiveType}}
{{^isPrimitiveType}}
result.{{{name}}}.replace(valueDes);
{{/isPrimitiveType}}
{{/isModel}}
{{^isContainer}}
{{^isModel}}
Expand Down

0 comments on commit 4b16589

Please sign in to comment.