Describe the bug
I am not yet sure how to reproduce which state, as I have two different observation:
Example 1:
Generated code:
from ...apimachinery.pkg.apis.meta import v1
from ..core import v1
(from: https://github.com/FlorianLudwig/pdk8s/blob/e9b5903c4f8cf584fe60a4a84709a42f7e63b771/pdk8s/gen/io/k8s/api/networking/v1beta1.py#L12)
Example 2:
Generated code:
from ...apimachinery.pkg.apis.meta import v1
from ..core import v1 as v1_1
(from: https://github.com/FlorianLudwig/pdk8s/blob/e9b5903c4f8cf584fe60a4a84709a42f7e63b771/pdk8s/gen/io/k8s/api/extensions/v1beta1.py)
In this example, the second import is renamed to avoid the collision but the references are not. Resulting in code trying to access module members that are in v1_1 but refer to v1. (Example)
Expected behavior
The second example is a step in the right direction (or maybe import more of the package name, in this example meta.v1 instead of just v1). But the references must be updated.
Version:
@FlorianLudwig
Thank you for your report
OK, I will research the problem.
I want to fix easy. but, we may need to refactor resolving class logic.
I just understood that I have to refactor the logic of referencing and resolving classes.
I hope to do it in this week or next week.
Thank you so much for your work! Looking forward to it.
Sorry, I'm busy this week.
I want to get the time next week.
@FlorianLudwig
I have fixed it and released a new version as 0.5.16
Hi @koxudaxi,
I just tested 0.5.16 and it seems like a regression to me.
Previously:
Now:
All but one enum are gone (diff of generated code: left old version, right after upgrade):


And the same enum is used everywhere.
Files:
edit: link to schema used was the wrong one
@FlorianLudwig
Thank you for the details of the problem.
Sorry, I have fixed and released a new version as 0.5.17
Also, I added a unittest for the case.
Hey @koxudaxi
thanks!
I tested against current master. Looks good!
(It looks like you didn't publish to pypi though)
@FlorianLudwig
Thank you for your report.
(It looks like you didn't publish to pypi though)
Really? :thinking:
I can look for some new versions in pypi.
https://pypi.org/project/datamodel-code-generator/#history
This is strange. I had the following error with poetry:
Because pdk8s depends on datamodel-code-generator (0.5.17) which doesn't match any versions, version solving failed.
Not sure what I did wrong, but is working now!