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
Such definitions will also validate on the OAS3 validators by Mermade and APIDevTools.
Currently, when such a spec is used, the invalid recursive type compile error occurs.
# github.com/grokify/go-ringcentral/codegen/engagevoice
../../../../codegen/engagevoice/model_agent_account_access.go:12:6: invalid recursive type AgentAccountAccess
../../../../codegen/engagevoice/model_campaign.go:12:6: invalid recursive type Campaign
../../../../codegen/engagevoice/model_custom_dial_zone_groups.go:12:6: invalid recursive type CustomDialZoneGroups
../../../../codegen/engagevoice/model_quota_target.go:12:6: invalid recursive type QuotaTarget
Describe the solution you'd like
The problem with circular definitions occurs in Go because the compiler cannot determine the size of such a struct. The solution is to replace the nested struct with a pointer, who's size is known, as described here:
A pointer's size is known, but how big is something that contains itself? (And the inner struct contains itself as well, as does the inner inner struct, and so on.)
Given how pointers are part of a long-running nullable discussion, one thought is to use a CLI parameter that will make all nested structs pointers as to make it an optional feature.
The text was updated successfully, but these errors were encountered:
Ran into this issue using the current go generator (go-experimental at the time this issue was created). Fixed it by manually updating the generated model files.
We've been hacking the generated files with a simple minded shell script to add pointers. @grokify thanks for the more robust hack than ours. Would be great to see this fixed in the generator though.
Is your feature request related to a problem? Please describe.
Valid OpenAPI specs can have circular definitions, however, this is not currently supported in generated Go client SDKs.
Validity of OpenAPI circular definitions is discussed here:
Such definitions will also validate on the OAS3 validators by Mermade and APIDevTools.
Currently, when such a spec is used, the
invalid recursive type
compile error occurs.Describe the solution you'd like
The problem with circular definitions occurs in Go because the compiler cannot determine the size of such a struct. The solution is to replace the nested struct with a pointer, who's size is known, as described here:
https://stackoverflow.com/a/8261789/1908967
This has been confirmed to compile by manually updating the generated model files.
Describe alternatives you've considered
None yet.
Additional context
null
value threads.Given how pointers are part of a long-running nullable discussion, one thought is to use a CLI parameter that will make all nested structs pointers as to make it an optional feature.
The text was updated successfully, but these errors were encountered: