Skip to content

[REQ] [go-gin-server] place models in different package to prevent circular package references #2752

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

Open
pconstantinou opened this issue Apr 27, 2019 · 2 comments

Comments

@pconstantinou
Copy link

Golang doesn't allow packages to have circular references. Currently, the go-gin-server implementation places the model and api definition code in the same package. This makes using models generated from OpenAPI difficult to use outside of the package.

Currently, for example, you can't have the API call a separate database package with a model object as a parameter, because it requires making circular package references.

Describe the solution you'd like

Ideally, there would be the option of having a separate model package from an API package.

Describe alternatives you've considered

The current workaround is either putting all your database code in the generated API objects or replicating the model objects within a separate package (duplicating code).

Additional context

The openapi generator libraries seem to allow for separate package and API names but those parameters are ignored by the go-gin-server generator.

#1931 also discusses this a similar issue

@auto-labeler
Copy link

auto-labeler bot commented Apr 27, 2019

👍 Thanks for opening this issue!
🏷 I have applied any labels matching special text in your issue.

The team will review the labels and make any necessary changes.

@nakajimayoshi
Copy link

Any further progress on this? It's very common to separate datalayer packages from the api package, and the inability to specify this at the generation level makes it so you have to couple the two, which is frustrating. It's the same problem with the go-server package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants