skqr/hateoas-bundle-example

Sending empty collection throws ERROR_NOT_ENTITY_COLLECTION exception.

Closed this issue · 5 comments

Sending a empty collection throws a exception.

URL: http://127.0.0.1:8000/api/v1/users
Method: POST.

Data:

{
  "users" : {
    "username" : "example",
    "email" : "menzo@example.com",
    "name" : "Menzo",
    "surname" : "Wijmenga",
    "password" : "passwor",
    "links" : {
      "user-groups" : [] 
    }  
  }
}

Exception:
ERROR_NOT_ENTITY_COLLECTION / "La relación "user-groups" contiene un , se esperaba una colección de entidades que implementase Collection."

File: GoIntegro\Bundle\HateoasBundle\JsonApi\EntityResource.php:173.

skqr commented

Hey! Thanks. On it 😸

skqr commented

I'll add a test for that too.

skqr commented

Really weird. Happens for /users but not for /posts. Investigating.

skqr commented

The exception is correct - the User model was not initializing the userGroupsvariable as an ArrayCollection.

skqr commented

(Also, I'm addressing the issue with i18n in the error messages ASAP.)