You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
The commit in the PR: #8491 which resolves the pointer issue missed the logic to perform similar operation in case of Unmarshalling of the JSON.
Link to commit: aeneasr@0c5e5ae
Due to this, there is a mismatch between the data type for BreedList property(This issue is seen for array of object type property) between Dog type and DogWithoutEmbeddedStruct type(Present inside UnmarshalJSON() method).
Following is the model schema used to reproduce the issue.
We can see that there is the difference between the type of BreedList inside Dog(which is a non-pointer type) and DogWithoutEmbeddedStruct type(Which is a pointer type).
Expected output:
No issues when the code is built.
Actual output:
go build -o myproject
./model_dog.go:149:20: cannot use varDogWithoutEmbeddedStruct.BreedList (type *[]map[string]interface {}) as type []map[string]interface {} in assignment
meghana-rajashekar
changed the title
Pass by value/Pass by Reference changes breaking Go client
[GO] Pass by value/Pass by Reference changes breaking Go client
Jan 31, 2022
meghana-rajashekar
changed the title
[GO] Pass by value/Pass by Reference changes breaking Go client
[BUG][GO] Pass by value/Pass by Reference changes breaking Go client
Jan 31, 2022
Bug Report Checklist
Description
The commit in the PR: #8491 which resolves the pointer issue missed the logic to perform similar operation in case of Unmarshalling of the JSON.
Link to commit: aeneasr@0c5e5ae
Due to this, there is a mismatch between the data type for BreedList property(This issue is seen for array of object type property) between Dog type and DogWithoutEmbeddedStruct type(Present inside UnmarshalJSON() method).
Following is the model schema used to reproduce the issue.
Snippet of spec file
The following Snippet of code is generated:
Definition for {{ classname }} struct generated at the beginning:
Definition of struct generated inside UnmarshalJSON() method:
We can see that there is the difference between the type of BreedList inside Dog(which is a non-pointer type) and DogWithoutEmbeddedStruct type(Which is a pointer type).
Expected output:
No issues when the code is built.
Actual output:
openapi-generator version
5.2.1
OpenAPI declaration file content or url
https://gist.githubusercontent.com/the-akhil-nair/ffd8a387e24e90b8759bc7a3f53fe0f0/raw/c69c490139a95351df5e03ff1a40e9099e0e0782/go_pbv_pbv_petstore_example.yaml
Generation Details
config.yaml file content:
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -i https://gist.githubusercontent.com/the-akhil-nair/ffd8a387e24e90b8759bc7a3f53fe0f0/raw/c69c490139a95351df5e03ff1a40e9099e0e0782/go_pbv_pbv_petstore_example.yaml -g go -o ../animal -c ../config.yaml
Steps to reproduce
Related issues/PRs
#8491
Suggest a fix
The logic used to define the struct for classname should also be reflected when it's defined for WithoutEmbeddedStruct inside UnmarshalJSON() method.
PR raised for the solution:
#11466
The text was updated successfully, but these errors were encountered: