-
Notifications
You must be signed in to change notification settings - Fork 39
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
Optional creator parameters #285
Conversation
Hi @Verdent , what about just enabling missing parameters and defaulting for primitives only? Seems it will be backward compatible functionally and avoids any new config. |
This solution is backwards compatible also. Where do you see the problem? I am not sure why do you think, that new config option is a bad thing. |
Agree.
Any toggle is a bad thing and has impact on downside libraries. A simple example is that most of the times the requirement of the value being passed is disabled in impl and consumers like schema generators consider it true by default, with such a toggle instead of aligning on all instantiations, it will require to be integrated in downside libs to be usable properly. Without the toggle we enable users for a long requested feature, don't really break anyone since the feature is broken as of today and we don't require libs/integrators to support a new toggle, so only goods IMHO to just change the doc/expectations and not the code.
Ok for me. |
23cb742
to
4327cc7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small changes - looks good!
api/src/main/java/jakarta/json/bind/annotation/JsonbRequired.java
Outdated
Show resolved
Hide resolved
api/src/main/java/jakarta/json/bind/annotation/JsonbRequired.java
Outdated
Show resolved
Hide resolved
Signed-off-by: David Kral <david.k.kral@oracle.com>
Signed-off-by: David Kral <david.k.kral@oracle.com>
…nbRequired Signed-off-by: David Kral <david.k.kral@oracle.com>
parameters are optional by default Signed-off-by: David Kral <david.k.kral@oracle.com>
Signed-off-by: David Kral <david.k.kral@oracle.com>
Signed-off-by: David Kral <david.k.kral@oracle.com>
Signed-off-by: David Kral <david.k.kral@oracle.com>
Signed-off-by: David Kral <david.k.kral@oracle.com>
Signed-off-by: David Kral <david.k.kral@oracle.com>
d9cc96a
to
8295425
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Any hope we drop @JsonbRequired and drop any misplaced validation from JSON-B to align it in jakarta platform and reduce the validation burden in JSON-B itself? Would also enable to use Records properly without any hack or new specificity which is a big pro instead of polluting the spec with new concepts IMHO. |
I don't see any misplaced validation to be fair. I am not sure what do you see as a problem between the records and this PR. Why are you still so much against adding anything to the spec? |
once again, requirement of a field is a validation, there is no validation in JSON-B except this one so if we go the validation way ( This is why I strongly think we should just relax the error done in 1.0 with a toggle for existing applications which could maybe rely on that - none in practise? ;) - and be it. Also note that current PR breaks 1.0/2.0 by changing the default and just adds the required validation API so I just request to not add the annotation and not let JSON-B validated anything. For records you can end up defining a constructor if you fix previous point (backward compat breakeage) whereas I don't want in most cases. If you keep it, it is ok for them and it is the same for records and classes. |
No we don't need to support anything else. This is no special validation. Just a requirement for it to be present in the JSON document in some way. Nothing else. That's the same as it is right now and we are not supporting any extended validation either. Any kind of validation is up to the user. We are not doing any.
And that's the reason why our current SNAPSHOT is 3.0.0. This PR will be introducing backwards breaking change. |
I am not sure how you would expect this change to be done... I used to have the switch on the config level to keep backwards compatibility, but you were against it. I removed that and you against it again? How do you expect this to be done? |
yes, it is not at config level but JVM level to keep existing app working. you need to change the config? you recompile so it does not work - and once again, for the 1 or 2 apps using that feature it is really about making it working with a global flag, not a jsonbconfig.withCompat() kind of thing IMHO. So more a
This is called a validation, no need to play with words. Look, being a number is a requirement on the type, right? Being between 1 and 10 is a requirement on the range of the value, right? It is all the same really and the impl must take care of the content instead of just binding it when possible, so at the end it is validation and out of mapping scope.
Well, in 1.0 no because presence validation is done and this is the only thing to relax in 2.1.
Well there are two things on that:
|
Not true. I was thinking of using Even if we call it validation, it doesn't change a thing. Since the current state is exactly like that and no extended validation is happening. There is no reason why we should introduce that. We are having
Well, from my point of view it is desirable to have a way, how to mark some parameters/creators as optional/required even when the global setting requires the different. |
Hmm, sorry @Verdent but it reads as "not true, you are right" from my side.
Does not make much sense for me because it is on serialization side, here we are talking about deserialization so nillable applies as a filter, not a validation in terms of design, no failure.
Ok, let's step back another time and explain you again the way I see it cause I don't disagree with the fact user should be able to handle this requirement but there are a few point we diverge in terms of design so let's explicit them one more time:
So overall, I can see the "it is easy to do so let's do" point but in terms of consistency, design and user need, it does not reach much its goal and you let the end user with the same exact need so let's just enable them - disable the default requirement of < 3.0 - and don't add any noise and incomplete feature. |
@JsonbRequired is added for a case when the parameters must be present. It cannot be considered validation. I am merging this PR and closing the issue. |
@m0mus -1, both statements don't make sense, let me explain why
Presence is a validation, no way to workaround it and it belongs to JSON-P - if desired - or application code as explained.
Jakarta (JavaEE) always supported java > now because it is what users expect. |
Fixes #121
I have decided to drop the new
@JsonbDefaultValue
annotation and focus on the basics first.