Skip to content

Commit 44bf1d6

Browse files
Bolswing328
authored andcommitted
Fix for self-referential imports in typescript-angular client (#6450)
1 parent 1f4013e commit 44bf1d6

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptAngularClientCodegen.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,19 +270,21 @@ public Map<String, Object> postProcessModels(Map<String, Object> objs) {
270270
for (Object _mo : models) {
271271
Map<String, Object> mo = (Map<String, Object>) _mo;
272272
CodegenModel cm = (CodegenModel) mo.get("model");
273-
mo.put("tsImports", toTsImports(cm.imports));
273+
mo.put("tsImports", toTsImports(cm,cm.imports));
274274
}
275275

276276
return result;
277277
}
278278

279-
private List<Map<String, String>> toTsImports(Set<String> imports) {
279+
private List<Map<String, String>> toTsImports(CodegenModel cm, Set<String> imports) {
280280
List<Map<String, String>> tsImports = new ArrayList<>();
281281
for(String im : imports) {
282+
if(!im.equals(cm.classname)) {
282283
HashMap<String, String> tsImport = new HashMap<>();
283284
tsImport.put("classname", im);
284285
tsImport.put("filename", toModelFilename(im));
285286
tsImports.add(tsImport);
287+
}
286288
}
287289
return tsImports;
288290
}

0 commit comments

Comments
 (0)