kiota: flatten models packages in Go to avoid unsupported circular references
For larger APIs, it is nice to put different parts of the model in different namespaces. For example, in our API, we’ve got over 40 types related to authentication and about 30 related to groups of users. In Java, we’ve put these classes in different subpackages, and I think this works well for other languages, such as C# as well. However, these types do have relations pointing to types in other subpackages, such as accounts being member of a group and the groups an account is member of. These dependencies often form cycles. This currently breaks code generation for Go, as Go does not allow circular dependencies between modules.
I’m not sure what the best way to fix this would be, but I guess the best solution would be to flatten the models modules in Go and generate one large module. I think cross-type relations are quite common in APIs and requiring the provider of the API to not use relations over namespaces does not seem viable to me. IMHO this should be implemented in the GoRefiner.
About this issue
- Original URL
- State: open
- Created a year ago
- Comments: 22 (22 by maintainers)
Yes, I agree. I think flattening is the go-way of doing it, but this can’t be done before v2. Trimming is a lot of work and hard to impossible to get deterministic. Let’s park this for v2.