@@ -9,34 +9,27 @@ import (
99 "github.com/pacedotdev/oto/parser"
1010)
1111
12- func ObjectGolang (def parser.Definition , parentField * parser. Field , object * parser.Object , tabs int ) template.HTML {
12+ func ObjectGolang (def parser.Definition , object * parser.Object , tabs int ) template.HTML {
1313 s := & strings.Builder {}
14- fmt .Fprintf (s , strings .Repeat ("\t " , tabs ))
15- if parentField != nil {
16- fmt .Fprintf (s , "%s{\b " , parentField .Type .ExternalObjectName )
17- }
14+ fmt .Fprintf (s , "%s{" , object .ExternalObjectName )
1815 for _ , field := range object .Fields {
1916 fmt .Fprintf (s , "\n " )
20- fmt .Fprintf (s , strings .Repeat ("\t " , tabs + 1 ))
17+ fmt .Fprint (s , strings .Repeat ("\t " , tabs + 1 ))
2118 if field .Type .IsObject {
2219 // object
2320 fieldObject , err := def .Object (field .Type .ObjectName )
2421 if err != nil {
2522 return template .HTML (field .Type .ObjectName + ": " + err .Error ())
2623 }
27- fmt .Fprintf (s , "%s: %s{\n %v" , field .Name , field .Type .ExternalObjectName , ObjectGolang (def , & field , fieldObject , tabs + 1 ))
28- fmt .Fprintf (s , "\n " )
29- fmt .Fprintf (s , strings .Repeat ("\t " , tabs + 1 ))
30- fmt .Fprintf (s , "}," )
24+ fmt .Fprintf (s , "%s: %v," , field .Name , ObjectGolang (def , fieldObject , tabs + 1 ))
3125 continue
3226 }
3327 // normal field
3428 fmt .Fprintf (s , "%s: %v," , field .Name , jsonStr (field .Metadata ["example" ]))
3529 }
36- fmt .Fprintf (s , strings .Repeat ("\t " , tabs + 1 ))
37- if parentField != nil {
38- fmt .Fprintf (s , "}" )
39- }
30+ fmt .Fprintf (s , "\n " )
31+ fmt .Fprint (s , strings .Repeat ("\t " , tabs ))
32+ fmt .Fprintf (s , "}" )
4033 return template .HTML (s .String ())
4134}
4235
0 commit comments