dict fix on pycli

master
Paulo Simão 2021-03-05 09:33:57 -03:00
parent 0943472bc4
commit 7674c28999
3 changed files with 15 additions and 13 deletions

6
go.mod
View File

@ -1,13 +1,11 @@
module go.digitalcircle.com.br/tools/apigen
go 1.15
go 1.16
require (
github.com/alecthomas/kong v0.2.12
github.com/bxcodec/faker/v3 v3.5.0 // indirect
github.com/alecthomas/kong v0.2.15
github.com/fatih/structtag v1.2.0
github.com/pkg/errors v0.9.1
github.com/yuin/stagparser v0.0.0-20181218160030-e10a81132760
go.digitalcircle.com.br/golib/base v0.0.0-20210124165830-341c1d300435
gopkg.in/yaml.v2 v2.4.0
)

13
go.sum
View File

@ -1,19 +1,16 @@
github.com/alecthomas/kong v0.2.12 h1:X3kkCOXGUNzLmiu+nQtoxWqj4U2a39MpSJR3QdQXOwI=
github.com/alecthomas/kong v0.2.12/go.mod h1:kQOmtJgV+Lb4aj+I2LEn40cbtawdWJ9Y8QLq+lElKxE=
github.com/bxcodec/faker v1.5.0 h1:RIWOeAcM3ZHye1i8bQtHU2LfNOaLmHuRiCo60mNMOcQ=
github.com/bxcodec/faker v2.0.1+incompatible h1:P0KUpUw5w6WJXwrPfv35oc91i4d8nf40Nwln+M/+faA=
github.com/bxcodec/faker/v3 v3.5.0 h1:Rahy6dwbd6up0wbwbV7dFyQb+jmdC51kpATuUdnzfMg=
github.com/bxcodec/faker/v3 v3.5.0/go.mod h1:gF31YgnMSMKgkvl+fyEo1xuSMbEuieyqfeslGYFjneM=
github.com/alecthomas/kong v0.2.15 h1:HP3K1XuFn0wGSWFGVW67V+65tXw/Ht8FDYiLNAuX2Ug=
github.com/alecthomas/kong v0.2.15/go.mod h1:kQOmtJgV+Lb4aj+I2LEn40cbtawdWJ9Y8QLq+lElKxE=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/fatih/structtag v1.2.0 h1:/OdNE99OxoI/PqaW/SuSK9uxxT3f/tcSZgon/ssNSx4=
github.com/fatih/structtag v1.2.0/go.mod h1:mBJUNpUnHmRKrKlQQlmCrh5PuhftFbNv8Ys4/aAZl94=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/yuin/stagparser v0.0.0-20181218160030-e10a81132760 h1:i+m5+M2renk/OmDHvzRjlBQXm+5X6WR6xPjWfHNzvcM=
github.com/yuin/stagparser v0.0.0-20181218160030-e10a81132760/go.mod h1:+qbo7cNcx8dT/77C41x4MZbasDrLuUDI/04ZGR/7IqM=
go.digitalcircle.com.br/golib/base v0.0.0-20210124165830-341c1d300435 h1:XVnDH9egiX/iTc59738ZozUZHGahb494y52oxmLJYN4=
go.digitalcircle.com.br/golib/base v0.0.0-20210124165830-341c1d300435/go.mod h1:8BeArwDJW81pf5Fhchrs/Hh2YSg0FMnNeaV+j1kUEyM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=

View File

@ -76,6 +76,7 @@ def InvokeTxt(path: str, method: str, body) -> str:
def InvokeJSON(path: str, method: str, body) -> dict:
d = body.__dict__
return json.loads(InvokeTxt(path, method, body))
`, api.BasePath))
@ -137,7 +138,13 @@ def InvokeJSON(path: str, method: str, body) -> dict:
//b.WriteString(fmt.Sprintf("/**\n%s*/\n", m.Desc))
}
b.WriteString(fmt.Sprintf("def %s(req:%s)-> %s:\n", k, _typeName(m.ReqType), _typeName(m.ResType)))
rettype := _typeName(m.ResType)
if rettype != "" {
b.WriteString(fmt.Sprintf("def %s(req:%s)-> %s:\n", k, _typeName(m.ReqType), rettype))
} else {
b.WriteString(fmt.Sprintf("def %s(req:%s):\n", k, _typeName(m.ReqType)))
}
b.WriteString(fmt.Sprintf("\treturn InvokeJSON(\"%s\",\"%s\",req)\n", m.Path, m.Verb))
b.WriteString(fmt.Sprintf("\n\n"))
//}