-
Notifications
You must be signed in to change notification settings - Fork 16
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
closes #293: allow empty options object in all commands #310
Conversation
// don't fail on unknown props, mainly for empty options object in commands | ||
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) |
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.
@tatu-at-datastax any better idea?
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.
We could (and probably should) use
@JsonIgnoreProperties({ "options" })
public interface Command {}
in a base class/interface. It can be applied either with annotations or using "configOverrides" (let me dig up reference), or using mix-in annotations.
This type of ignoral is only used in case there is no explicit property (unlike @JsonIgnore
that forcibly prevents use) so it should not prevent use of non-empty "ignores" cases.
It'd probably be better to do that so we don't accidentally hide properties with typos etc.
Also: we could enable "fail all unknown" just on Command types with
@JsonIgnoreProperties(ignoreUnknown = true)
and not globally.
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.
Ok so "Config overrides" work like so:
ObjectMapper mapper = JsonMapper.builder()
.withConfigOverride(Point.class,
cfg -> cfg.setIgnorals(JsonIgnoreProperties.Value.forIgnoredProperties("y")))
.build();
and let one apply equivalent of @JsonIgnoreProperties
on any type. But one big limitation is that it only works on exact target class, but not base class.
So I think what we can use is:
@JsonIgnoreProperties({ "options" })
public interface Command {}
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.
Done in 50a276f
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.
The proposal does not work, it completely omits options
even in the commands that should have them.. See https://github.com/stargate/jsonapi/actions/runs/4562316051/jobs/8049363613
Reverting to previous solution..
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.
Alas. Sorry about suggesting that; you are right.
@tatu-at-datastax @maheshrajamani Can we try to keep the integration tests clean and readable please, by following the below guidelines.. I know I can be perfectionist, but it's way better when we have everything nice and readable:
Thanks.. |
@ivansenic On clean up, naming; good ideas. Only one counterpoint: for bigger tests (which is most ITs over time), context of single test makes it less easy to see the surrounding context. So sometimes little bit of redundancy on actual method name is useful when editing tests, scrolling back and forth. I realize it won't be necessary on left-side result tree, but as long as it's nothing super long may be useful. Thank you for doing the cleanup; I have started dropping |
2399667
to
50a276f
Compare
Thanks for understanding.. Names are fine, we can not get wrong with that.. Regarding json, I expect formatted JSON, with 2 spaces indentation, smth like: |
50a276f
to
771d9ae
Compare
771d9ae
to
226475f
Compare
Ah ok, yes, that's fine, makes sense. |
@ivansenic I do have alternate solution to ignoral; instead of works. Basically default "setter" in |
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 👍
What this PR does:
Allows mongoose to send empty options object even when a command does not support any options. Confirmed it was failing before.
Which issue(s) this PR fixes:
Fixes #293
Checklist