-
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
Support use of @JsonValue on enums for CRD generation #6443
Comments
@andreaTP created this new issue based on the discussion here: |
@shawkins thanks for the quick reply! Sorry if this a silly question, but how do you specify the version of the generator? I see there is a separate maven module for I'm doing this through the Quarkus framework if that means anything. |
You'd have to check with the JOSDK folks, but I don't think they have release yet that aligns to the v2 generator. |
Ah ok thank you, lets say taking JOSDK out of the picture... A project with:
Using version Running
Java 21 |
Your example won't work regardless of the java version, because the annotation processor in If you need api-v2 now (with 6.13.x), I would recommend to backport the new CRD-Generator maven plugin. It has been designed to work with api-v2 from the beginning. I have done something similar last week and it worked out of the box. As far as I know there is no official backport planned. But I think we should talk about it. Non-Quarkus users are otherwise not able to use api-v2 with v6. (For Quarkus, see quarkiverse/quarkus-operator-sdk#927) |
Is your enhancement related to a problem? Please describe
I have a Java
enum
that is generated from an Open API spec, and the generatedenum
uses@JsonValue
on a getter to indicate the value to use for serialization. It also generates a staticfromValue
method with@JsonCreator
.Example:
I want to use this field in a custom resource that generates the CRD from the Java classes, but the generated CRD is not using the values from the method with
@JsonValue
, so the enum items have all the values from thename()
method likeVALUE_A
,VALUE_B
.I assume this is because this code here only looks for
@JsonProperty
:https://github.com/fabric8io/kubernetes-client/blob/main/crd-generator/api/src/main/java/io/fabric8/crd/generator/AbstractJsonSchema.java#L114
Describe the solution you'd like
I would like to see if it is possible to also consider
@JsonValue
in the code linked above that processes enumerations and looks for an alternate value to use for the enum value.Describe alternatives you've considered
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: