Open danielchatfield opened 3 years ago
Thanks for reporting this, I'm having the exact same issue. @danielchatfield did you ever find a workaround that didn't involve re-editing the client code after generation?
When I look at the mustache template for the model it looks like it supports non-struct types so it's not clear why it's generating struct types for arrays. See: https://github.com/swagger-api/swagger-codegen/blob/35adbd552d5f99b3ff1e0e59da228becc85190f2/modules/swagger-codegen/src/main/resources/go/model.mustache#L8
I don't know much about java but it looks like the model's type is being determined here: https://github.com/swagger-api/swagger-codegen/blob/35adbd552d5f99b3ff1e0e59da228becc85190f2/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractGoCodegen.java#L226. Maybe someone else who understands this better can provide some insight?
Edit: Also note, it looks like initially when the code was added there may have been support for arrays but it got commented out: https://github.com/swagger-api/swagger-codegen/pull/7197/commits/1bd77278af10f5fd5a2afe72bc0b983746efcf65#diff-218fa02fec22b278ce7a40c9fbee90a6f7bacf730a693f5a7f5b5e8ae3aadac0R51-R52 @bvwells I know it's been a while but any idea what the problem might have been and specifically why this was commented out?
/*instantiationTypes.put("array", "GoArray");
instantiationTypes.put("map", "GoMap");*/
Description
If an API has an array of objects it currently produces broken Go code – it produces an empty struct rather than a type that represents a slice of objects.
Swagger-codegen version
2.4.17
Swagger declaration file content or url
A minimal example can be seen by generating a Go client from the following.
Command line used for generation
Used
editor.swagger.io
Steps to reproduce
Paste the above into
editor.swagger.io
and then click generate Go client.Suggest a fix/enhancement