Skip to content

Commit

Permalink
fix(python): use proper struct default value
Browse files Browse the repository at this point in the history
The old {} default value caused problems in the python template when
it was looking the specific type having a .dict() field on default
values.
  • Loading branch information
w4bremer committed Jun 1, 2023
1 parent 9f90228 commit b909322
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion pkg/gen/filters/filterpy/py_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ func ToDefaultString(schema *model.Schema, prefix string) (string, error) {
if s == nil {
return "xxx", fmt.Errorf("ToDefaultString struct %s not found", schema.Type)
}
text = "{}"
ident := common.CamelTitleCase(s.Name)
text = fmt.Sprintf("%s%s()", prefix, ident)
case model.TypeInterface:
i := schema.Module.LookupInterface(schema.Type)
if i == nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/gen/filters/filterpy/py_default_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func TestDefaultSymbolsFromIdl(t *testing.T) {
rt string
}{
{"test", "Test2", "propEnum", "Enum1.DEFAULT"},
{"test", "Test2", "propStruct", "{}"},
{"test", "Test2", "propStruct", "Struct1()"},
{"test", "Test2", "propInterface", "None"},
{"test", "Test2", "propEnumArray", "[]"},
{"test", "Test2", "propStructArray", "[]"},
Expand Down

0 comments on commit b909322

Please sign in to comment.