-
Notifications
You must be signed in to change notification settings - Fork 6k
[GO] Self-referencing definitions result in generating 'recursive' and thus invalid structs #3565
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
Labels
Milestone
Comments
It is indeed related. This is indeed an additional reason to use pointers. |
ivucica
added a commit
to ivucica/swagger-codegen
that referenced
this issue
Aug 10, 2016
We could try to avoid this for some base types, but Go's JSON encoder should treat this well enough. Addresses swagger-api#3565 and swagger-api#2330.
ivucica
added a commit
to ivucica/swagger-codegen
that referenced
this issue
Aug 23, 2016
We could try to avoid this for some base types, but Go's JSON encoder should treat this well enough. Addresses swagger-api#3565 and swagger-api#2330.
Current master produces code that compiles for this specification now. |
@ivucica please pull the latest master to give it a try. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Description
Because structs and not pointers to structs are used in the generated code, a
definition
cannot refer to itself.Swagger-codegen version
7a245e3
Swagger declaration file content or url
Full file available at https://bitbucket.org/api/swagger.json (it may change, but that's out of my control)
Also https://bitbucket.org/ivucica/calendarify/src/f1297e3411fcb52e830bd02dd0108e85eed39488/vendor/bitbucket.org/api/swagger.json
Command line used for generation
See https://bitbucket.org/ivucica/calendarify/src/f1297e3411fcb52e830bd02dd0108e85eed39488/vendor/bitbucket.org/api/BUILD
Versions of dependencies: https://bitbucket.org/ivucica/calendarify/src/f1297e3411fcb52e830bd02dd0108e85eed39488/WORKSPACE
Versions of swagger projects: https://bitbucket.org/ivucica/calendarify/src/f1297e3411fcb52e830bd02dd0108e85eed39488/vendor/github.com/swagger-api/
Steps to reproduce
Bitbucket's API contains the following definition (transformed from JSON into YAML by the Swagger editor):
Generated code looks like:
This results in a build error in Go such as:
Related issues
I am unaware of any.
Suggest a Fix
Consider updating the generated code to have properties of definitions generated as pointer types of struct fields.
To maintain compatibility with preexisting code that assumes fields are not pointers, this could be done only in case a definition refers to itself.
The text was updated successfully, but these errors were encountered: