-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
CRD generation does not support defaults, enums are incorrect #5324
Comments
The crd generator is only aware of select jackson annotations. It's mostly based upon sundrio, not jackson. In this case I think the generator is aware of JsonProperty, but not JsonSerialize. Using something like https://github.com/FasterXML/jackson-module-jsonSchema has been talked about briefly, but that is not suitable annoation processing logic - the whole crd generator would need to be re-designed around running as a separate build step so it could use the compiled classes. |
We could make a special case for this particular use case, which seems to be rather common, though. Handling the default value probably would be more tricky since, at least in this case, it would mean understanding the code that the field is assigned this value by default, which is not how the generator works at all (it only looks at types and annotations, not the code itself). |
The analysis made by @shawkins makes total sense to me. Regarding the two issues discussed here:
|
Poking around there also seems to be quite a few challenges. It also does not understand things like custom serialization via JsonSerialize either - with that annotation, it gives up and emits:
It supports a different set of constraint annotations, jakarta.validation.constraints.* And I'm sure there's a lot more to be found after digging into it. Perhaps we should do something similar when we see jsonserialize - effectively widen, rather than creating a potentially incorrect schema. Or alternatively warn. |
I poked around a little bit as well, I was thinking we could instantiate the JsonSerializer referenced by the annotation and call it when outputting the value but even in the case of a simple |
I brought up in our meeting that it may be possible to bridge between jackson and sundrio. However that does seem like a very difficult task - the JavaType logic is just one part of it, all of the com.fasterxml.jackson.databind.introspect would need abstracted to work with sundrio and you'd have to at the very least convert to Annotation instances. I'd say the initial assessment stands the jackson logic could only run after the the classes were compiled. |
This issue has been automatically marked as stale because it has not had any activity since 90 days. It will be closed if no further activity occurs within 7 days. Thank you for your contributions! |
This issue is completely solved as of today:
Please, re-open if you find any additional bugs or edge cases! |
@andreaTP I found this issue while searching to see if there was a way to get a generated CRD to use |
@bbende do you mind opening a new issue? |
Describe the bug
Using the CRD generator, defaults are not handled at all and enumerations are handled incorrectly.
Fabric8 Kubernetes Client version
SNAPSHOT
Steps to reproduce
See this example class:
This generates the following CRD:
There are two issues here:
status
.toString()
representations.Expected behavior
The CRD should look like this:
Runtime
minikube
Kubernetes API Server version
1.25.3@latest
Environment
Linux
Fabric8 Kubernetes Client Logs
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: