From 7674c289993721ee7d45114948a8caa85966f534 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paulo=20Sima=CC=83o?= Date: Fri, 5 Mar 2021 09:33:57 -0300 Subject: [PATCH] dict fix on pycli --- go.mod | 6 ++---- go.sum | 13 +++++-------- src/processPyClientOutput.go | 9 ++++++++- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/go.mod b/go.mod index bb89f0a..0214405 100644 --- a/go.mod +++ b/go.mod @@ -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 ) diff --git a/go.sum b/go.sum index 7dc2059..ae0138a 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/src/processPyClientOutput.go b/src/processPyClientOutput.go index b5d654d..1156aca 100644 --- a/src/processPyClientOutput.go +++ b/src/processPyClientOutput.go @@ -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")) //}