fix: duplicate model generation

This commit is contained in:
Lea Anthony
2022-04-05 21:30:55 +10:00
parent eb97f53124
commit 55855ccc4d
2 changed files with 22 additions and 10 deletions
+7 -1
View File
@@ -83,9 +83,14 @@ func (b *Bindings) ToJSON() (string, error) {
func (b *Bindings) WriteModels(modelsDir string) error {
models := map[string]string{}
var seen slicer.StringSlicer
for packageName, structsToGenerate := range b.structsToGenerateTS {
thisPackageCode := ""
for _, structInterface := range structsToGenerate {
for structName, structInterface := range structsToGenerate {
fqstructname := packageName + "." + structName
if seen.Contains(fqstructname) {
continue
}
w := typescriptify.New()
w.Namespace = packageName
w.WithBackupDir("")
@@ -95,6 +100,7 @@ func (b *Bindings) WriteModels(modelsDir string) error {
return err
}
thisPackageCode += str
seen.AddSlice(w.GetGeneratedStructs())
}
models[packageName] = thisPackageCode
}