-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[Enhancement] CrdGenerator validate @JsonPropertyOrder #2779
Comments
@tombentley this is a great idea. A question of implementation, would you want this to fail a build if any of the above validations fail, or print them out as warnings? |
Fail the build. People usually overlook warnings. |
Stage 1 of Issue 2779 Validate @JsonPropertyOrder present for all CRD classes and subclasses with exception of Java primitive `Object` Added test class to validate this new functionality and added Exception: InvalidCrdException Followup PRs will see the check that JsonPropertyOrder contains exactly all of the classes fields and these fields will be ordered for each individual class Contributes to: strimzi#2779 Signed-off-by: Samuel Hawker <samuel.hawker@ibm.com>
Stage 1 of Issue 2779 Validate @JsonPropertyOrder present for all CRD classes and subclasses with exception of Java primitive `Object` Added test class to validate this new functionality and added Exception: InvalidCrdException Followup PRs will see the check that JsonPropertyOrder contains exactly all of the classes fields and these fields will be ordered for each individual class Contributes to: strimzi#2779 Signed-off-by: Samuel Hawker <samuel.hawker@ibm.com>
I haven't had time to finish this. If someone wants to pick this up, feel free to look at my above closed PR #2820 |
Where does the property order actually matter? When working on the |
Triaged on 7.6.2022: We should either validate it or remove it completely. But right now it is not clear what is it actually useful for. @tombentley why do you think we should have this and define the order? |
It mostly doesn't matter, because whatever order we use it's only honoured when it's us serializing the JSON. That's why |
Triaged on 21st June: We should validate that all fields are present at build time. |
Hello @scholzj Is this still relevant? If so, I'd like to give it a go. |
I think the expectation is that it will check if:
If the annotation or some fields is missing, it should raise the error and fail. The PR adding this feature should also update any of the missing fields so that we can merge it without failing the main build. And then once it is merged, when new field is added tot he API but not to the property order or when a new class is added without the property order, it would simply fail the build and force the user to fix it. |
Sounds good @scholzj. Just to clarify, when you say Secondly, how can we identify the classes requiring Ill take a look at this one :) |
No, what the check should do is:
it would apply to all the POJO classes in the |
Makes sense, thanks @scholzj :) This is already what I did, so makes sense. |
Signed-off-by: Steffen Karlsson <steffen.karlsson@maersk.com>
Can we improve the
CrdGenerator
to:@JsonPropertyOrder
is presentThe text was updated successfully, but these errors were encountered: