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
{{ message }}
Repository navigation
refactor: Replace the models package with one models module, which contains all models #636
Is your feature request related to a problem? Please describe.
One of the issues that block implementation of #466 or #563 is circular import occurs in the case of circular and recursive references.
Describe the solution you'd like
I want to move the generated models to one module because it simplifies the support of circular and recursive reference development. See #563 and #466. Seems @maz808's pull request #563 solves several problems with references and would be great to finish it and merge. But it contains a circular import problem. I've described it this message.
I've already implemented a possible solution in this branch. Maybe it's done not enough accurately but seems it's working. I want to receive feedback to complete this and #563.
Describe alternatives you've considered
The alternate solution is to continue using package models with a separate module for each model. We may prevent the circular import problem by David Beasley hack, using this statement in the model template:
try:
from ..modelsimporta_circular_modelexceptImportError:
importsyschange=sys.modules[__package__+"a_circular_model"]
It also will produce the working client code, but it has more complexity. I believe the one module is more ergonomic. Because for instance one of my OpenAPI specs has a lot of circular references. In that case, it produces a lot of strings with the statements, I've mentioned above. It will look like
Activity
dbanty commentedon Sep 18, 2022
Superseded by the approach in #670!