-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG][Go][Bounty] Go client generator doesn't support deepObject in query #11401
Comments
Same with v5.4.0 and latest. |
I meet the similar problem in the path parameters. I guess it is because of this line |
Similar issue on our end, we just added a $250 bounty on this one: https://app.bountysource.com/issues/112016967-bug-go-go-client-generator-doesn-t-support-deepobject-in-query |
The given example works fine with 6.2.0. Do you have another example which does not work? |
I will check it and maybe will find another example. Thanks for the comment. |
test result
Output is valid ...
if r.filter != nil {
localVarQueryParams.Add("filter", parameterToString(*r.filter, ""))
}
...
// TestFilterParameter struct for TestFilterParameter
type TestFilterParameter struct {
// Filter.
Search *string `json:"search,omitempty"`
} but logic is wrong func parameterToString(obj interface{}, collectionFormat string) string {
var delimiter string
switch collectionFormat {
case "pipes":
delimiter = "|"
case "ssv":
delimiter = " "
case "tsv":
delimiter = "\t"
case "csv":
delimiter = ","
}
if reflect.TypeOf(obj).Kind() == reflect.Slice {
return strings.Trim(strings.Replace(fmt.Sprint(obj), " ", delimiter, -1), "[]")
} else if t, ok := obj.(time.Time); ok {
return t.Format(time.RFC3339)
}
return fmt.Sprintf("%v", obj)
} it makes an API call with something like this package main
import "fmt"
type TestFilterParameter struct {
// Filter.
Search *string `json:"search,omitempty"`
}
func (t TestFilterParameter) GoString() string {
return "yop"
}
func (t TestFilterParameter) String() string {
return "yep"
}
func main() {
s := "query"
obj := TestFilterParameter{&s}
fmt.Printf("%v\n", obj)
fmt.Printf("%#v\n", obj)
} |
Full example package main
import (
"context"
"fmt"
"testme/openapi"
)
type TestFilterParameter struct {
// Filter.
Search *string `json:"search,omitempty"`
}
func (t TestFilterParameter) GoString() string {
return "yop"
}
func (t TestFilterParameter) String() string {
return "yep"
}
func main() {
q := "query"
obj := TestFilterParameter{&q}
fmt.Printf("%v\n", obj)
fmt.Printf("%#v\n", obj)
ctx := context.Background()
cl := openapi.NewAPIClient(openapi.NewConfiguration())
req := cl.DefaultApi.Test(ctx)
req = req.Filter(openapi.TestFilterParameter{Search: &q})
resp, err := cl.DefaultApi.TestExecute(req)
fmt.Println(resp, err)
} Expected call |
Hi all, i've created a PR for this feature, please review it. |
Any feedback on this? |
is this issue still open? |
It should just be merged and closed.
Il Dom 30 Ott 2022, 22:11 Akshit Tyagi ***@***.***> ha
scritto:
… is this issue still open?
—
Reply to this email directly, view it on GitHub
<#11401 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AWGJD4BJE3DYW4EJFNITLILWF3P75ANCNFSM5MZI7K2A>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
@parvit I know nothing about the bounty. I closed it because I no longer wait for it and use a different stack. Feel free to reopen the issue, but I will unsubscribe from it. |
…ecification (#13909) * issue #11401 - Go client generator doesn't support deepObject in query * samples generation * fix generation * fix generation * generated samples # Conflicts: # samples/client/petstore/go/go-petstore/model_200_response.go # samples/client/petstore/go/go-petstore/model_additional_properties_any_type.go # samples/client/petstore/go/go-petstore/model_client.go * Fixed unit tests * revert to http connection for tests * fix model_simple generation * Fix parameter encoding issue * simplified routine * fix test url * adapted for latest master, necessary generation * samples generation * sync with new master, regenerate samples * added api client test
@wing328 Is the code on the latest docker image? |
@wing328 Tested today with the latest image (built 16 hours ago), and same results on my end. |
do you mind sharing the spec so that we can use it to reproduce the issue? |
@wing328 Retested from scratch with latest image, and it works as expected. Don't know why it was failing few days ago. Maybe a problem between the keyboard and the chair. |
Bug Report Checklist
Description
Go client generator doesn't support deepObject in query.
openapi-generator version
v5.3.1
OpenAPI declaration file content or url
Generation Details
$ docker run --rm -it \ -v "$(pwd)"/api.yaml:/specs/api.yaml \ openapitools/openapi-generator-cli:v5.3.1 generate -i /specs/api.yaml -g go -o /sdk/go
Steps to reproduce
expected result: exit code 0 and successful generated content
actual result:
Related issues/PRs
Suggest a fix
The text was updated successfully, but these errors were encountered: