[TypeScript-Fetch] Generate oneOf schemas as type unions (#2617)

* Generate oneOf schemas as type unions for typescript-fetch

* Adjust oneOf imports to only include refs of oneOf
This commit is contained in:
Tim
2019-04-10 09:58:07 -07:00
committed by William Cheng
parent d63f4bc16a
commit 3036d8fd20
3 changed files with 31 additions and 0 deletions

View File

@@ -165,6 +165,16 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
}
}
}
if (cm.oneOf.size() > 0) {
// For oneOfs only import $refs within the oneOf
TreeSet<String> oneOfRefs = new TreeSet<String>();
for (String im : cm.imports) {
if (cm.oneOf.contains(im)) {
oneOfRefs.add(im);
}
}
cm.imports = oneOfRefs;
}
}
return objs;