HalBuilder / halbuilder-core

HalBuilder Core
38 stars 26 forks source link

Collections are not added to _embedded. #34

Closed mg-2014 closed 7 years ago

mg-2014 commented 7 years ago

Hi,

This issue applies to v5.0.1-SNAPSHOT (and/or the current "develop" branch).

As soon as you add a second representation with .withRepresentation() or use .withRel(Rels.collection()) the representations are moved out of the _embedded elements to the outer element.

A single .withRepresentation("item", ...) is added to _embedded as expected:

{
   "_embedded": {
      "item": {
         ...
      }
   }
}

But if I use .withRel(Rels.collection("item") or add a second .withRepresentation("item", ...) the _embedded elements is empty and the representations are moved to the outer object:

{
   "_embedded": {},
   "item": [
      {
         ...
      },
      ...
   ]
}

The problem seems to be JsonRepresentationWriter.java:145 which uses

objectNode.set(rel.rel(), embedArrayNode);

instead of

embedsNode.set(rel.rel(), embedArrayNode);

A question aside from the issue: When will v5.0.1 be available on Maven Central? Apart the from the mentioned issue v5.0.1-SNAPSHOT seems to work perfectly for me. The README.md hints that I should use com.theoryinpractise:halbuilder5:5.0.1-SNAPSHOT from Maven Central. But unfortunately I'm not allowed to use any SNAPSHOT dependencies from Maven Central. Our artifact repository won't even download them.

Regards, Markus

talios commented 7 years ago

@mg-2014 thanks for the bug report! I'd not had much time to look at HalBuilder for awhile so thanks for the proding as well. I did a burst of work once Vavr 0.9.0 was released but got side tracked again with $work and concerts.

Once this issue is addressed, I don't really see any reason not to make an initial release rather than languish without use.

talios commented 7 years ago

com.theoryinpractise:halbuilder5:5.0.1 released and should now be winging it's way to Maven Central. Call this a silent release for now - I suppose I should write up a blog post or something.

mg-2014 commented 7 years ago

Hi Mark, thank you for fixing the issue and releasing it on Maven Central. It's available on Maven Central as of today and I've added it as a dependency to our project.

Regards, Markus