Skip to content
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][model] Collection initialized to empty collection even if not required #3585

Closed
jmini opened this issue Aug 8, 2019 · 4 comments · Fixed by #3615
Closed

[java][model] Collection initialized to empty collection even if not required #3585

jmini opened this issue Aug 8, 2019 · 4 comments · Fixed by #3615

Comments

@jmini
Copy link
Member

jmini commented Aug 8, 2019

We are trying to use the same model between our client (using a model serialized with Jackson) and server (JaxRS jersey2).

If a collection is not required, the server model set its value to null.

{{#isContainer}}
private {{{datatypeWithEnum}}} {{name}}{{#required}} = {{{defaultValue}}}{{/required}}{{^required}} = null{{/required}};
{{/isContainer}}
{{^isContainer}}
private {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};
{{/isContainer}}

This is not the case on client side.

private {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};

In my opinion this should be aligned.

@auto-labeler
Copy link

auto-labeler bot commented Aug 8, 2019

👍 Thanks for opening this issue!
🏷 I have applied any labels matching special text in your issue.

The team will review the labels and make any necessary changes.

@bkabrda
Copy link
Contributor

bkabrda commented Aug 8, 2019

👍 from my side. It also leads to problems like always sending empty {} when you don't touch a value of that attribute, which can be problematic when doing PATCH requests that are only expected to change certain parts of the resource, but with this issue they actually reset some attributes to empty.

@viclovsky
Copy link
Contributor

I use rest-assured client for testing.
The issue leads to inability to check that a field is definitely absent (by comparing by null), because collections are always empty.

@jmini
Copy link
Member Author

jmini commented Aug 12, 2019

@bkabrda thank you for your feedback, you wrote exactly what I wanted to add. This is a valid argument for people who are interested only in the java-client (and do not care about client and server being aligned).


I have proposed the change in PR #3615

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants