[Go] report correctly the parameters with the deep object specification#13909
[Go] report correctly the parameters with the deep object specification#13909wing328 merged 16 commits intoOpenAPITools:masterfrom
Conversation
# 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
|
@wing328 Here's the update PR you requested. |
|
can you please update the samples ? also I believe you've tested it locally, right? Can you post the test result as well? |
|
I'll need to update the mustache files first as now they don't generate correct code anymore. |
|
take your time. just let me know when it's ready. i'll review over the weekend or next week. have a nice weekend. |
|
again please make sure this PR is created from the latest master. |
|
@wing328 EDIT: Retesting from clean state i was not able to reproduce that issue, maybe it was just a local change that was throwing me off course |
|
@wing328 Were you able to check the change? |
|
can you please resolve the merge conflicts when you've time? I'll try to test again over the weekend. |
|
ok but after i do it please give it priority for merging
Il Ven 18 Nov 2022, 17:47 William Cheng ***@***.***> ha
scritto:
… can you please resolve the merge conflicts when you've time?
I'll try to test again over the weekend.
—
Reply to this email directly, view it on GitHub
<#13909 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AWGJD4BXDAQCCRZUJF3L5S3WI6XKHANCNFSM6AAAAAARW3RROM>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
# Conflicts: # modules/openapi-generator/src/main/resources/go/model_simple.mustache # modules/openapi-generator/src/main/resources/go/utils.mustache # samples/client/petstore/go/go-petstore/model_animal.go # samples/client/petstore/go/go-petstore/model_category.go # samples/client/petstore/go/go-petstore/model_enum_test_.go # samples/client/petstore/go/go-petstore/model_format_test_.go # samples/client/petstore/go/go-petstore/model_name.go # samples/client/petstore/go/go-petstore/model_pet.go # samples/client/petstore/go/go-petstore/model_type_holder_default.go # samples/client/petstore/go/go-petstore/model_type_holder_example.go # samples/client/petstore/go/go-petstore/utils.go # samples/openapi3/client/extensions/x-auth-id-alias/go-experimental/utils.go # samples/openapi3/client/petstore/go/go-petstore/model_animal.go # samples/openapi3/client/petstore/go/go-petstore/model_apple_req.go # samples/openapi3/client/petstore/go/go-petstore/model_banana_req.go # samples/openapi3/client/petstore/go/go-petstore/model_category.go # samples/openapi3/client/petstore/go/go-petstore/model_duplicated_prop_parent.go # samples/openapi3/client/petstore/go/go-petstore/model_enum_test_.go # samples/openapi3/client/petstore/go/go-petstore/model_format_test_.go # samples/openapi3/client/petstore/go/go-petstore/model_name.go # samples/openapi3/client/petstore/go/go-petstore/model_pet.go # samples/openapi3/client/petstore/go/go-petstore/model_whale.go # samples/openapi3/client/petstore/go/go-petstore/model_zebra.go # samples/openapi3/client/petstore/go/go-petstore/utils.go
|
@wing328 the update is done |
|
I did a test and got the following in tcpdump:
What are those F1, F2, F3 ? Here is a test I added to pet_api_test.go // test deep object query parameter and verify via tcpdump
func TestDeepObjectQuery(t *testing.T) {
newPet := (sw.Pet{Id: sw.PtrInt64(12830), Name: "gopher",
PhotoUrls: []string{"http://1.com", "http://2.com"}, Status: sw.PtrString("pending"),
Tags: []sw.Tag{{Id: sw.PtrInt64(1), Name: sw.PtrString("tag2")}}})
newCategory := (sw.Category{Id: sw.PtrInt64(12830), Name: "cat"})
configuration := sw.NewConfiguration()
apiClient := sw.NewAPIClient(configuration)
r, err := apiClient.FakeApi.TestQueryDeepObject(context.Background()).TestPet(newPet).InputOptions(newCategory).Execute()
if err != nil {
// for sure this will fail as the endpoint is fake
}
if r.StatusCode != 200 {
t.Log(r)
}
}Can you please also include it in your PR so that we've a test ready for testing next time? Thanks again for the PR. |
|
The names come from the data in the AdditionalProperties map in the test i already made in fake_api_test.go, because i wanted to stress the deep reflection path of the code to confirm it works. func TestQueryDeepObject(t *testing.T) {
req := client.FakeApi.TestQueryDeepObject(context.Background())
var id = int64(1)
var idTag1 = int64(2)
var nameTag1 = "tag1"
req = req.TestPet(sw.Pet{
Id: &id,
Name: "Test",
PhotoUrls: []string{ "http://localhost" },
Tags: []sw.Tag{
{
Id: &idTag1,
Name: &nameTag1,
AdditionalProperties: map[string]interface{}{
"F1": 1,
"F2": "teststring",
"F3": nil,
},
},
},
AdditionalProperties: map[string]interface{}{
"F1": 1,
"F2": "teststring",
"F3": nil,
},
})
var idcat = int64(1)
req = req.InputOptions(sw.Category{
Id: &idcat,
Name: "TestCat",
AdditionalProperties: map[string]interface{}{
"F1": 1,
"F2": "teststring",
"F3": nil,
},
})
r, _ := req.Execute()
var expectedDeepObjectURL = testScheme + "://" + testHost + deepObjectURL
assert.Equal(t,
expectedDeepObjectURL,
r.Request.URL.String() )
} |
|
Thanks for the explanation 👍 . I can confirm in my end the result is good. |

Hi all,
this change addresses the issue mentioned in #11401 and it should report correctly the parameters with the deep object specification.
Commits cherry-picked from previous branch to be based on current master