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
[java-gen] Support Min/Max/Pattern javax.validation.constraints #3870
Comments
Just as a reference the complete list (as of today) of available annotations generated but the |
Ah. Would be nice to have a round-trip test as well |
Pretty confident they will come soon (I have some POCs for this already). |
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! |
Hi, any news about this annotations support? |
Hi @leoandrea7 , this is not supported yet, although it might be relatively straightforward to implement it. Let's see if @fabiobrz gets intrigued enough 😏 , but, in general, would you mind sharing your use case? |
I have a CRD with openAPIV3Schema like this:
The problem is that crd-generator does not generate the fields minimum, maximum and pattern. Thanks a lot @andreaTP! |
@leoandrea7 quick sanity check, you mentioned Also nullable is already integrated in the current implementation (i.e. 6.0.0-RC1) when you are experiencing any issue with it, please, file an issue 🙏 |
I assume that comes from Strimzi? Last I heard, they do use Java operator SDK, so might already have models you would need instead of generating them? |
AFAIK Strimzi doesn't use JOSDK (so far) but straight client |
No it is a custom CRD. The "kafka" field has nothing to do with Strimzi. |
Anyway
Actually I need it on the crd-generator, but I thought they were a single tool.. |
There is need of a new issue for crd-gen? Thanks |
@leoandrea7 the CRD and Java generators should possibly eventually converge, but they are, ATM two separate tools, so please, file a separate issue (and, possibly, the one on Nullable) |
That seems to be written as a duplicate. I think the ask was to make a ticket only for any issues you're having with the nullable fields. The schemas linked in the original post are openAPIV3Schema Edit: ignore. I see you're asking for crd-gen ; since you showed yaml already, I'd assumed you already had that |
Hi @OneCricketeer, @andreaTP - IIUC the scope for this issue is just about OpenAPI v3 Schema based validation, right? i.e. what described in here - specifically the |
No, this issue was requesting to add POJO annotations, unrelated to YAML/OpenAPI spec/schema validation, but POJO's created from those YAML files. |
Thanks @OneCricketeer - I think I just worded my question badly, sorry about that. |
@fabiobrz Sorry, I still don't understand. Look at the links in the original issue description. The min max and pattern fields are part of the openapiv3 schema section of those crds |
Hi @OneCricketeer - I think we're on the same page. I've looked at the links in the description already. This issue is for tracking the work needed to make java-gen support the generation of "validation" annotations, like for instance Solving the two issues that you linked above (#4348 and #4384) will not solve this very issue, because they will support the generation of Fabric8 annotations - i.e. those belonging defined by |
@fabiobrz One of the linked tickets discussed doing away with JavaEE annotation dependency (I recall someone called them deprecated or abandoned, or bloat...?) and thus why the new annotation module was created to keep external dependencies at a minimum. |
Yes, I as well have read such discussion in one of the related issues.
Exactly. #4384 is for generating the new annotations, not the Hence, given what we say here, it seems this can be closed or put on-hold. WDYT? |
Fine by me. Moving discussion to #4384 |
Is your enhancement related to a problem? Please describe
I noticed that
required
fields get a@NotNull
annotation applied, but there are other supported validation patterns that can be applied to generated Java models as wellhttps://javaee.github.io/tutorial/bean-validation002.html
Describe the solution you'd like
Examples
kubernetes-client/java-generator/core/src/test/resources/akka-microservices-crd.yml
Lines 48 to 49 in 1d7d869
Mapped to
kubernetes-client/java-generator/core/src/test/resources/akka-microservices-crd.yml
Lines 75 to 76 in 1d7d869
Mapped to
Describe alternatives you've considered
Manually adding these where they would be needed.
Additional context
The objects will fail to be constructed if an invalid value is provided when the annotations are present.
Use-case: Preventing bad user-provided input fields into an API layer.
The text was updated successfully, but these errors were encountered: