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

Tried to fix https://github.com/api-platform/core/issues/1025 #1046

Closed
wants to merge 4 commits into from
Closed

Tried to fix https://github.com/api-platform/core/issues/1025 #1046

wants to merge 4 commits into from

Conversation

nik-lampe
Copy link

Q A
Bug fix? yes
New feature? no
BC breaks? n/a
Deprecations? no
Tests pass? n/a
Fixed tickets #1234, #5678
License MIT
Doc PR api-platform/docs#1234

This is my WIP Pull Request adressing issue #1025
I am not sure, if this does not break something else...

@nik-lampe
Copy link
Author

nik-lampe commented Apr 11, 2017

I don't think that these are all occurrences where the wrong resourceClass is passed via the context. There might be more, especially regarding setting values. I haven't tried that

@@ -60,7 +60,7 @@ public function supportsNormalization($data, $format = null)
*/
public function normalize($object, $format = null, array $context = [])
{
$resourceClass = $this->resourceClassResolver->getResourceClass($object, $context['resource_class'] ?? null, true);
$resourceClass = $this->resourceClassResolver->getResourceClass($object, get_class($object), true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is wrong, the resourceClassResolver already does this. If you want to fix this, you should try to fix it in the ResourceClassResolver class directly.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, yes I see.
Then I guess it is sufficient to pass null as resourceClass parameter

@@ -79,7 +79,7 @@ public function supportsNormalization($data, $format = null)
*/
public function normalize($object, $format = null, array $context = [])
{
$resourceClass = $this->resourceClassResolver->getResourceClass($object, $context['resource_class'] ?? null, true);
$resourceClass = $this->resourceClassResolver->getResourceClass($object, get_class($object), true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

@soyuka
Copy link
Member

soyuka commented Apr 12, 2017

This will still break things, I don't think it's the correct way of fixing the inheritance issue.

Quoting my comment on api-platform/api-platform#277 :

Then there is #1025. This is indeed a bug where the Parent entity is not aware of the Child metadata. Therefore, it can not serialize properties it doesn't know of. This is harder to fix, because the metadata is the one from Parent::class though it should be Parent::class + Child::class. The good question there is "how do we find every child that extends the parent?".
An easy fix is might be to patch this class by retrieving the metadata for table inheritance.

@nik-lampe
Copy link
Author

nik-lampe commented Apr 12, 2017

I am myself not sure if it's the correct way to fix this either. You guys wanted me to create the WIP pull request, so it might be easier to track down the problem.

The thing is, that these changes fixed the issue for me in my project. For #1025 as well as for #1043. Though these two issues seem not to be related. I never wanted to say that this is the right fix for it...
But maybe my assumption that it has to do with inheritance was wrong?

Yes it might break things. I am waiting for it in my project.
Actually I thought that it would definitely break things, but so far it is working fine... 🤷‍♂️

@soyuka
Copy link
Member

soyuka commented Apr 12, 2017

You guys wanted me to create the WIP pull request, so it might be easier to track down the problem.

Yes indeed, that's good to help us find the best solution together :D.

Actually I thought that it would definitely break things, but so far it is working fine... 🤷‍♂️

By breaking, I mean that our test suite won't pass with your changes, it's therefore creating bugs.


Instead of trying to fix this directly, I would first add a failing behat test. This will then be the starting point to fix the issue. Though, if there are two different issues we need to do this one issue at a time!
If you think that the issue is not related to inheritance, I propose we try to find a failing test case for the serialization issue first!

@dunglas
Copy link
Member

dunglas commented Apr 15, 2017

The tests look almost green but the 500 error thrown in the Behat test is weird. Do you have an idea of the problem @nik-lampe? You can get a better stack trace by running behat -vvv.

@bwegrzyn
Copy link
Contributor

bwegrzyn commented Apr 17, 2017

@dunglas It appears that this test case fails because of these changes. While these changes fix my failing test case in #1063, it looks like it breaks something else.

Click to expand Scenario: Filter with a raw URL # features/hydra/collection.feature:283
  Scenario: Filter with a raw URL                                                         # features/hydra/collection.feature:283
    When I send a "GET" request to "/dummies?id=%2fdummies%2f8"                           # Behatch\Context\RestContext::iSendARequestTo()
    Then print last JSON response                                                         # Behatch\Context\JsonContext::printLastJsonResponse()
      │ {
      │     "@context": "\/contexts\/Error",
      │     "@type": "hydra:Error",
      │     "hydra:title": "An error occurred",
      │     "hydra:description": "Resource \"Proxies\\__CG__\\ApiPlatform\\Core\\Tests\\Fixtures\\TestBundle\\Entity\\Dummy\" not found.",
      │     "trace": [
      │         {
      │             "namespace": "",
      │             "short_class": "",
      │             "class": "",
      │             "type": "",
      │             "function": "",
      │             "file": "\/Users\/bwegrzyn\/dev\/GitHub Forks\/api-platform-core\/src\/Metadata\/Resource\/Factory\/ExtractorResourceMetadataFactory.php",
      │             "line": 74,
      │             "args": []
      │         },
      │         {
      │             "namespace": "ApiPlatform\\Core\\Metadata\\Resource\\Factory",
      │             "short_class": "ExtractorResourceMetadataFactory",
      │             "class": "ApiPlatform\\Core\\Metadata\\Resource\\Factory\\ExtractorResourceMetadataFactory",
      │             "type": "->",
      │             "function": "handleNotFound",
      │             "file": "\/Users\/bwegrzyn\/dev\/GitHub Forks\/api-platform-core\/src\/Metadata\/Resource\/Factory\/ExtractorResourceMetadataFactory.php",
      │             "line": 52,
      │             "args": [
      │                 [
      │                     "null",
      │                     null
      │                 ],
      │                 [
      │                     "string",
      │                     "Proxies\\__CG__\\ApiPlatform\\Core\\Tests\\Fixtures\\TestBundle\\Entity\\Dummy"
      │                 ]
      │             ]
      │         },
      │         {
      │             "namespace": "ApiPlatform\\Core\\Metadata\\Resource\\Factory",
      │             "short_class": "ExtractorResourceMetadataFactory",
      │             "class": "ApiPlatform\\Core\\Metadata\\Resource\\Factory\\ExtractorResourceMetadataFactory",
      │             "type": "->",
      │             "function": "create",
      │             "file": "\/Users\/bwegrzyn\/dev\/GitHub Forks\/api-platform-core\/src\/Metadata\/Resource\/Factory\/PhpDocResourceMetadataFactory.php",
      │             "line": 44,
      │             "args": [
      │                 [
      │                     "string",
      │                     "Proxies\\__CG__\\ApiPlatform\\Core\\Tests\\Fixtures\\TestBundle\\Entity\\Dummy"
      │                 ]
      │             ]
      │         },
      │         {
      │             "namespace": "ApiPlatform\\Core\\Metadata\\Resource\\Factory",
      │             "short_class": "PhpDocResourceMetadataFactory",
      │             "class": "ApiPlatform\\Core\\Metadata\\Resource\\Factory\\PhpDocResourceMetadataFactory",
      │             "type": "->",
      │             "function": "create",
      │             "file": "\/Users\/bwegrzyn\/dev\/GitHub Forks\/api-platform-core\/src\/Metadata\/Resource\/Factory\/ShortNameResourceMetadataFactory.php",
      │             "line": 37,
      │             "args": [
      │                 [
      │                     "string",
      │                     "Proxies\\__CG__\\ApiPlatform\\Core\\Tests\\Fixtures\\TestBundle\\Entity\\Dummy"
      │                 ]
      │             ]
      │         },
      │         {
      │             "namespace": "ApiPlatform\\Core\\Metadata\\Resource\\Factory",
      │             "short_class": "ShortNameResourceMetadataFactory",
      │             "class": "ApiPlatform\\Core\\Metadata\\Resource\\Factory\\ShortNameResourceMetadataFactory",
      │             "type": "->",
      │             "function": "create",
      │             "file": "\/Users\/bwegrzyn\/dev\/GitHub Forks\/api-platform-core\/src\/Metadata\/Resource\/Factory\/OperationResourceMetadataFactory.php",
      │             "line": 37,
      │             "args": [
      │                 [
      │                     "string",
      │                     "Proxies\\__CG__\\ApiPlatform\\Core\\Tests\\Fixtures\\TestBundle\\Entity\\Dummy"
      │                 ]
      │             ]
      │         },
      │         {
      │             "namespace": "ApiPlatform\\Core\\Metadata\\Resource\\Factory",
      │             "short_class": "OperationResourceMetadataFactory",
      │             "class": "ApiPlatform\\Core\\Metadata\\Resource\\Factory\\OperationResourceMetadataFactory",
      │             "type": "->",
      │             "function": "create",
      │             "file": "\/Users\/bwegrzyn\/dev\/GitHub Forks\/api-platform-core\/src\/Metadata\/Resource\/Factory\/CachedResourceMetadataFactory.php",
      │             "line": 55,
      │             "args": [
      │                 [
      │                     "string",
      │                     "Proxies\\__CG__\\ApiPlatform\\Core\\Tests\\Fixtures\\TestBundle\\Entity\\Dummy"
      │                 ]
      │             ]
      │         },
      │         {
      │             "namespace": "ApiPlatform\\Core\\Metadata\\Resource\\Factory",
      │             "short_class": "CachedResourceMetadataFactory",
      │             "class": "ApiPlatform\\Core\\Metadata\\Resource\\Factory\\CachedResourceMetadataFactory",
      │             "type": "->",
      │             "function": "create",
      │             "file": "\/Users\/bwegrzyn\/dev\/GitHub Forks\/api-platform-core\/src\/Metadata\/Property\/Factory\/SerializerPropertyMetadataFactory.php",
      │             "line": 158,
      │             "args": [
      │                 [
      │                     "string",
      │                     "Proxies\\__CG__\\ApiPlatform\\Core\\Tests\\Fixtures\\TestBundle\\Entity\\Dummy"
      │                 ]
      │             ]
      │         },
      │         {
      │             "namespace": "ApiPlatform\\Core\\Metadata\\Property\\Factory",
      │             "short_class": "SerializerPropertyMetadataFactory",
      │             "class": "ApiPlatform\\Core\\Metadata\\Property\\Factory\\SerializerPropertyMetadataFactory",
      │             "type": "->",
      │             "function": "getEffectiveSerializerGroups",
      │             "file": "\/Users\/bwegrzyn\/dev\/GitHub Forks\/api-platform-core\/src\/Metadata\/Property\/Factory\/SerializerPropertyMetadataFactory.php",
      │             "line": 53,
      │             "args": [
      │                 [
      │                     "array",
      │                     {
      │                         "collection_operation_name": [
      │                             "string",
      │                             "get"
      │                         ]
      │                     }
      │                 ],
      │                 [
      │                     "string",
      │                     "Proxies\\__CG__\\ApiPlatform\\Core\\Tests\\Fixtures\\TestBundle\\Entity\\Dummy"
      │                 ]
      │             ]
      │         },
      │         {
      │             "namespace": "ApiPlatform\\Core\\Metadata\\Property\\Factory",
      │             "short_class": "SerializerPropertyMetadataFactory",
      │             "class": "ApiPlatform\\Core\\Metadata\\Property\\Factory\\SerializerPropertyMetadataFactory",
      │             "type": "->",
      │             "function": "create",
      │             "file": "\/Users\/bwegrzyn\/dev\/GitHub Forks\/api-platform-core\/src\/Bridge\/Symfony\/Validator\/Metadata\/Property\/ValidatorPropertyMetadataFactory.php",
      │             "line": 50,
      │             "args": [
      │                 [
      │                     "string",
      │                     "Proxies\\__CG__\\ApiPlatform\\Core\\Tests\\Fixtures\\TestBundle\\Entity\\Dummy"
      │                 ],
      │                 [
      │                     "string",
      │                     "__initializer__"
      │                 ],
      │                 [
      │                     "array",
      │                     {
      │                         "collection_operation_name": [
      │                             "string",
      │                             "get"
      │                         ]
      │                     }
      │                 ]
      │             ]
      │         },
      │         {
      │             "namespace": "ApiPlatform\\Core\\Bridge\\Symfony\\Validator\\Metadata\\Property",
      │             "short_class": "ValidatorPropertyMetadataFactory",
      │             "class": "ApiPlatform\\Core\\Bridge\\Symfony\\Validator\\Metadata\\Property\\ValidatorPropertyMetadataFactory",
      │             "type": "->",
      │             "function": "create",
      │             "file": "\/Users\/bwegrzyn\/dev\/GitHub Forks\/api-platform-core\/src\/Metadata\/Property\/Factory\/CachedPropertyMetadataFactory.php",
      │             "line": 55,
      │             "args": [
      │                 [
      │                     "string",
      │                     "Proxies\\__CG__\\ApiPlatform\\Core\\Tests\\Fixtures\\TestBundle\\Entity\\Dummy"
      │                 ],
      │                 [
      │                     "string",
      │                     "__initializer__"
      │                 ],
      │                 [
      │                     "array",
      │                     {
      │                         "collection_operation_name": [
      │                             "string",
      │                             "get"
      │                         ]
      │                     }
      │                 ]
      │             ]
      │         },
      │         {
      │             "namespace": "ApiPlatform\\Core\\Metadata\\Property\\Factory",
      │             "short_class": "CachedPropertyMetadataFactory",
      │             "class": "ApiPlatform\\Core\\Metadata\\Property\\Factory\\CachedPropertyMetadataFactory",
      │             "type": "->",
      │             "function": "create",
      │             "file": "\/Users\/bwegrzyn\/dev\/GitHub Forks\/api-platform-core\/src\/Serializer\/AbstractItemNormalizer.php",
      │             "line": 134,
      │             "args": [
      │                 [
      │                     "string",
      │                     "Proxies\\__CG__\\ApiPlatform\\Core\\Tests\\Fixtures\\TestBundle\\Entity\\Dummy"
      │                 ],
      │                 [
      │                     "string",
      │                     "__initializer__"
      │                 ],
      │                 [
      │                     "array",
      │                     {
      │                         "collection_operation_name": [
      │                             "string",
      │                             "get"
      │                         ]
      │                     }
      │                 ]
      │             ]
      │         },
      │         {
      │             "namespace": "ApiPlatform\\Core\\Serializer",
      │             "short_class": "AbstractItemNormalizer",
      │             "class": "ApiPlatform\\Core\\Serializer\\AbstractItemNormalizer",
      │             "type": "->",
      │             "function": "getAllowedAttributes",
      │             "file": "\/Users\/bwegrzyn\/dev\/GitHub Forks\/api-platform-core\/vendor\/symfony\/serializer\/Normalizer\/AbstractObjectNormalizer.php",
      │             "line": 121,
      │             "args": [
      │                 [
      │                     "object",
      │                     "Proxies\\__CG__\\ApiPlatform\\Core\\Tests\\Fixtures\\TestBundle\\Entity\\Dummy"
      │                 ],
      │                 [
      │                     "array",
      │                     {
      │                         "collection_operation_name": [
      │                             "string",
      │                             "get"
      │                         ],
      │                         "resource_class": [
      │                             "string",
      │                             "ApiPlatform\\Core\\Tests\\Fixtures\\TestBundle\\Entity\\Dummy"
      │                         ],
      │                         "request_uri": [
      │                             "string",
      │                             "\/dummies?id=%2fdummies%2f8"
      │                         ],
      │                         "jsonld_has_context": [
      │                             "boolean",
      │                             true
      │                         ],
      │                         "api_sub_level": [
      │                             "boolean",
      │                             true
      │                         ],
      │                         "api_normalize": [
      │                             "boolean",
      │                             true
      │                         ],
      │                         "cache_key": [
      │                             "string",
      │                             "f7c2150e55a31d8adbd0e311eba949be"
      │                         ],
      │                         "circular_reference_limit": [
      │                             "array",
      │                             {
      │                                 "000000005d2b89bd0000000024413b00": [
      │                                     "integer",
      │                                     1
      │                                 ]
      │                             }
      │                         ]
      │                     }
      │                 ],
      │                 [
      │                     "boolean",
      │                     true
      │                 ]
      │             ]
      │         },
      │         {
      │             "namespace": "Symfony\\Component\\Serializer\\Normalizer",
      │             "short_class": "AbstractObjectNormalizer",
      │             "class": "Symfony\\Component\\Serializer\\Normalizer\\AbstractObjectNormalizer",
      │             "type": "->",
      │             "function": "getAttributes",
      │             "file": "\/Users\/bwegrzyn\/dev\/GitHub Forks\/api-platform-core\/vendor\/symfony\/serializer\/Normalizer\/AbstractObjectNormalizer.php",
      │             "line": 70,
      │             "args": [
      │                 [
      │                     "object",
      │                     "Proxies\\__CG__\\ApiPlatform\\Core\\Tests\\Fixtures\\TestBundle\\Entity\\Dummy"
      │                 ],
      │                 [
      │                     "string",
      │                     "jsonld"
      │                 ],
      │                 [
      │                     "array",
      │                     {
      │                         "collection_operation_name": [
      │                             "string",
      │                             "get"
      │                         ],
      │                         "resource_class": [
      │                             "string",
      │                             "ApiPlatform\\Core\\Tests\\Fixtures\\TestBundle\\Entity\\Dummy"
      │                         ],
      │                         "request_uri": [
      │                             "string",
      │                             "\/dummies?id=%2fdummies%2f8"
      │                         ],
      │                         "jsonld_has_context": [
      │                             "boolean",
      │                             true
      │                         ],
      │                         "api_sub_level": [
      │                             "boolean",
      │                             true
      │                         ],
      │                         "api_normalize": [
      │                             "boolean",
      │                             true
      │                         ],
      │                         "cache_key": [
      │                             "string",
      │                             "f7c2150e55a31d8adbd0e311eba949be"
      │                         ],
      │                         "circular_reference_limit": [
      │                             "array",
      │                             {
      │                                 "000000005d2b89bd0000000024413b00": [
      │                                     "integer",
      │                                     1
      │                                 ]
      │                             }
      │                         ]
      │                     }
      │                 ]
      │             ]
      │         },
      │         {
      │             "namespace": "Symfony\\Component\\Serializer\\Normalizer",
      │             "short_class": "AbstractObjectNormalizer",
      │             "class": "Symfony\\Component\\Serializer\\Normalizer\\AbstractObjectNormalizer",
      │             "type": "->",
      │             "function": "normalize",
      │             "file": "\/Users\/bwegrzyn\/dev\/GitHub Forks\/api-platform-core\/src\/Serializer\/AbstractItemNormalizer.php",
      │             "line": 88,
      │             "args": [
      │                 [
      │                     "object",
      │                     "Proxies\\__CG__\\ApiPlatform\\Core\\Tests\\Fixtures\\TestBundle\\Entity\\Dummy"
      │                 ],
      │                 [
      │                     "string",
      │                     "jsonld"
      │                 ],
      │                 [
      │                     "array",
      │                     {
      │                         "collection_operation_name": [
      │                             "string",
      │                             "get"
      │                         ],
      │                         "resource_class": [
      │                             "string",
      │                             "ApiPlatform\\Core\\Tests\\Fixtures\\TestBundle\\Entity\\Dummy"
      │                         ],
      │                         "request_uri": [
      │                             "string",
      │                             "\/dummies?id=%2fdummies%2f8"
      │                         ],
      │                         "jsonld_has_context": [
      │                             "boolean",
      │                             true
      │                         ],
      │                         "api_sub_level": [
      │                             "boolean",
      │                             true
      │                         ],
      │                         "api_normalize": [
      │                             "boolean",
      │                             true
      │                         ],
      │                         "cache_key": [
      │                             "string",
      │                             "f7c2150e55a31d8adbd0e311eba949be"
      │                         ],
      │                         "circular_reference_limit": [
      │                             "array",
      │                             {
      │                                 "000000005d2b89bd0000000024413b00": [
      │                                     "integer",
      │                                     1
      │                                 ]
      │                             }
      │                         ]
      │                     }
      │                 ]
      │             ]
      │         },
      │         {
      │             "namespace": "ApiPlatform\\Core\\Serializer",
      │             "short_class": "AbstractItemNormalizer",
      │             "class": "ApiPlatform\\Core\\Serializer\\AbstractItemNormalizer",
      │             "type": "->",
      │             "function": "normalize",
      │             "file": "\/Users\/bwegrzyn\/dev\/GitHub Forks\/api-platform-core\/src\/JsonLd\/Serializer\/ItemNormalizer.php",
      │             "line": 69,
      │             "args": [
      │                 [
      │                     "object",
      │                     "Proxies\\__CG__\\ApiPlatform\\Core\\Tests\\Fixtures\\TestBundle\\Entity\\Dummy"
      │                 ],
      │                 [
      │                     "string",
      │                     "jsonld"
      │                 ],
      │                 [
      │                     "array",
      │                     {
      │                         "collection_operation_name": [
      │                             "string",
      │                             "get"
      │                         ],
      │                         "resource_class": [
      │                             "string",
      │                             "ApiPlatform\\Core\\Tests\\Fixtures\\TestBundle\\Entity\\Dummy"
      │                         ],
      │                         "request_uri": [
      │                             "string",
      │                             "\/dummies?id=%2fdummies%2f8"
      │                         ],
      │                         "jsonld_has_context": [
      │                             "boolean",
      │                             true
      │                         ],
      │                         "api_sub_level": [
      │                             "boolean",
      │                             true
      │                         ],
      │                         "api_normalize": [
      │                             "boolean",
      │                             true
      │                         ]
      │                     }
      │                 ]
      │             ]
      │         },
      │         {
      │             "namespace": "ApiPlatform\\Core\\JsonLd\\Serializer",
      │             "short_class": "ItemNormalizer",
      │             "class": "ApiPlatform\\Core\\JsonLd\\Serializer\\ItemNormalizer",
      │             "type": "->",
      │             "function": "normalize",
      │             "file": "\/Users\/bwegrzyn\/dev\/GitHub Forks\/api-platform-core\/vendor\/symfony\/serializer\/Serializer.php",
      │             "line": 142,
      │             "args": [
      │                 [
      │                     "object",
      │                     "Proxies\\__CG__\\ApiPlatform\\Core\\Tests\\Fixtures\\TestBundle\\Entity\\Dummy"
      │                 ],
      │                 [
      │                     "string",
      │                     "jsonld"
      │                 ],
      │                 [
      │                     "array",
      │                     {
      │                         "collection_operation_name": [
      │                             "string",
      │                             "get"
      │                         ],
      │                         "resource_class": [
      │                             "string",
      │                             "ApiPlatform\\Core\\Tests\\Fixtures\\TestBundle\\Entity\\Dummy"
      │                         ],
      │                         "request_uri": [
      │                             "string",
      │                             "\/dummies?id=%2fdummies%2f8"
      │                         ],
      │                         "jsonld_has_context": [
      │                             "boolean",
      │                             true
      │                         ],
      │                         "api_sub_level": [
      │                             "boolean",
      │                             true
      │                         ]
      │                     }
      │                 ]
      │             ]
      │         },
      │         {
      │             "namespace": "Symfony\\Component\\Serializer",
      │             "short_class": "Serializer",
      │             "class": "Symfony\\Component\\Serializer\\Serializer",
      │             "type": "->",
      │             "function": "normalize",
      │             "file": "\/Users\/bwegrzyn\/dev\/GitHub Forks\/api-platform-core\/src\/Hydra\/Serializer\/CollectionNormalizer.php",
      │             "line": 82,
      │             "args": [
      │                 [
      │                     "object",
      │                     "Proxies\\__CG__\\ApiPlatform\\Core\\Tests\\Fixtures\\TestBundle\\Entity\\Dummy"
      │                 ],
      │                 [
      │                     "string",
      │                     "jsonld"
      │                 ],
      │                 [
      │                     "array",
      │                     {
      │                         "collection_operation_name": [
      │                             "string",
      │                             "get"
      │                         ],
      │                         "resource_class": [
      │                             "string",
      │                             "ApiPlatform\\Core\\Tests\\Fixtures\\TestBundle\\Entity\\Dummy"
      │                         ],
      │                         "request_uri": [
      │                             "string",
      │                             "\/dummies?id=%2fdummies%2f8"
      │                         ],
      │                         "jsonld_has_context": [
      │                             "boolean",
      │                             true
      │                         ],
      │                         "api_sub_level": [
      │                             "boolean",
      │                             true
      │                         ]
      │                     }
      │                 ]
      │             ]
      │         },
      │         {
      │             "namespace": "ApiPlatform\\Core\\Hydra\\Serializer",
      │             "short_class": "CollectionNormalizer",
      │             "class": "ApiPlatform\\Core\\Hydra\\Serializer\\CollectionNormalizer",
      │             "type": "->",
      │             "function": "normalize",
      │             "file": "\/Users\/bwegrzyn\/dev\/GitHub Forks\/api-platform-core\/src\/Hydra\/Serializer\/PartialCollectionViewNormalizer.php",
      │             "line": 48,
      │             "args": [
      │                 [
      │                     "object",
      │                     "ApiPlatform\\Core\\Bridge\\Doctrine\\Orm\\Paginator"
      │                 ],
      │                 [
      │                     "string",
      │                     "jsonld"
      │                 ],
      │                 [
      │                     "array",
      │                     {
      │                         "collection_operation_name": [
      │                             "string",
      │                             "get"
      │                         ],
      │                         "resource_class": [
      │                             "string",
      │                             "ApiPlatform\\Core\\Tests\\Fixtures\\TestBundle\\Entity\\Dummy"
      │                         ],
      │                         "request_uri": [
      │                             "string",
      │                             "\/dummies?id=%2fdummies%2f8"
      │                         ],
      │                         "jsonld_has_context": [
      │                             "boolean",
      │                             true
      │                         ],
      │                         "api_sub_level": [
      │                             "boolean",
      │                             true
      │                         ]
      │                     }
      │                 ]
      │             ]
      │         },
      │         {
      │             "namespace": "ApiPlatform\\Core\\Hydra\\Serializer",
      │             "short_class": "PartialCollectionViewNormalizer",
      │             "class": "ApiPlatform\\Core\\Hydra\\Serializer\\PartialCollectionViewNormalizer",
      │             "type": "->",
      │             "function": "normalize",
      │             "file": "\/Users\/bwegrzyn\/dev\/GitHub Forks\/api-platform-core\/src\/Hydra\/Serializer\/CollectionFiltersNormalizer.php",
      │             "line": 59,
      │             "args": [
      │                 [
      │                     "object",
      │                     "ApiPlatform\\Core\\Bridge\\Doctrine\\Orm\\Paginator"
      │                 ],
      │                 [
      │                     "string",
      │                     "jsonld"
      │                 ],
      │                 [
      │                     "array",
      │                     {
      │                         "collection_operation_name": [
      │                             "string",
      │                             "get"
      │                         ],
      │                         "resource_class": [
      │                             "string",
      │                             "ApiPlatform\\Core\\Tests\\Fixtures\\TestBundle\\Entity\\Dummy"
      │                         ],
      │                         "request_uri": [
      │                             "string",
      │                             "\/dummies?id=%2fdummies%2f8"
      │                         ]
      │                     }
      │                 ]
      │             ]
      │         },
      │         {
      │             "namespace": "ApiPlatform\\Core\\Hydra\\Serializer",
      │             "short_class": "CollectionFiltersNormalizer",
      │             "class": "ApiPlatform\\Core\\Hydra\\Serializer\\CollectionFiltersNormalizer",
      │             "type": "->",
      │             "function": "normalize",
      │             "file": "\/Users\/bwegrzyn\/dev\/GitHub Forks\/api-platform-core\/vendor\/symfony\/serializer\/Serializer.php",
      │             "line": 142,
      │             "args": [
      │                 [
      │                     "object",
      │                     "ApiPlatform\\Core\\Bridge\\Doctrine\\Orm\\Paginator"
      │                 ],
      │                 [
      │                     "string",
      │                     "jsonld"
      │                 ],
      │                 [
      │                     "array",
      │                     {
      │                         "collection_operation_name": [
      │                             "string",
      │                             "get"
      │                         ],
      │                         "resource_class": [
      │                             "string",
      │                             "ApiPlatform\\Core\\Tests\\Fixtures\\TestBundle\\Entity\\Dummy"
      │                         ],
      │                         "request_uri": [
      │                             "string",
      │                             "\/dummies?id=%2fdummies%2f8"
      │                         ]
      │                     }
      │                 ]
      │             ]
      │         },
      │         {
      │             "namespace": "Symfony\\Component\\Serializer",
      │             "short_class": "Serializer",
      │             "class": "Symfony\\Component\\Serializer\\Serializer",
      │             "type": "->",
      │             "function": "normalize",
      │             "file": "\/Users\/bwegrzyn\/dev\/GitHub Forks\/api-platform-core\/vendor\/symfony\/serializer\/Serializer.php",
      │             "line": 115,
      │             "args": [
      │                 [
      │                     "object",
      │                     "ApiPlatform\\Core\\Bridge\\Doctrine\\Orm\\Paginator"
      │                 ],
      │                 [
      │                     "string",
      │                     "jsonld"
      │                 ],
      │                 [
      │                     "array",
      │                     {
      │                         "collection_operation_name": [
      │                             "string",
      │                             "get"
      │                         ],
      │                         "resource_class": [
      │                             "string",
      │                             "ApiPlatform\\Core\\Tests\\Fixtures\\TestBundle\\Entity\\Dummy"
      │                         ],
      │                         "request_uri": [
      │                             "string",
      │                             "\/dummies?id=%2fdummies%2f8"
      │                         ]
      │                     }
      │                 ]
      │             ]
      │         }
      |         ...
      │     ]
      │ }
    Then the response status code should be 200                                           # Behat\MinkExtension\Context\MinkContext::assertResponseStatus()
      Current response status code is 500, but 200 expected.

      +--[ HTTP/1.1 500 | http://example.com/dummies?id=%2fdummies%2f8 | KernelDriver ]
      |
      |  {"@context":"\/contexts\/Error","@type":"hydra:Error","hydra:title":"An error occurred","hydra:description":"Resource \u0022Proxies\\__CG__\\ApiPlatform\\Core\\Tests\\Fixtures\\TestBundle\\Entity\\Dummy\u0022 not found.","trace":[{"namespace":"","short_class":"","class":"","type":"","function":"","file":"\/Users\/bwegrzyn\/dev\/GitHub Forks\/api-platform-core\/src\/Metadata\/Resource\/Factory\/ExtractorResourceMetadataFactory.php","line":74,"args":[]},{"namespace":"ApiPlatform\\Core\\Metadata\\Resource\\Factory","short_class":"ExtractorResourceMetadataFactory","class":"ApiPlatform\\Core\\Metadata\\Resource\\Factory\\ExtractorResourceMetadataFactory","type":"-\u003E","function":"handleNotFound","file":"\/Users\/bwegrzyn\/dev\/GitHub Forks\/api-platform-core\/src\/Metadata\/Resource\/Factory\/ExtractorResourceMetadataFactory.php","line":52,"args":[["null",null],["string","Proxies\\__CG__\\ApiPlatform\\Core\\Tests\\Fixtures\\TestBundle\\Entity\\Dummy"]]},{"namespace":"ApiPlatform\\Core...
      |
    And the response should be in JSON                                                    # Behatch\Context\JsonContext::theResponseShouldBeInJson()
    And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8" # Behatch\Context\RestContext::theHeaderShouldBeEqualTo()
    And the JSON should be valid according to this schema:                                # Behatch\Context\JsonContext::theJsonShouldBeValidAccordingToThisSchema()
      """
      {
        "type": "object",
        "properties": {
          "@context": {"pattern": "^/contexts/Dummy$"},
          "@id": {"pattern": "^/dummies$"},
          "@type": {"pattern": "^hydra:Collection$"},
          "hydra:totalItems": {"type":"number", "maximum": 1},
          "hydra:member": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "@id": {"pattern": "^/dummies/8$"}
              }
            },
            "maxItems": 1
          },
          "hydra:view": {
            "type": "object",
            "properties": {
              "@id": {"pattern": "^/dummies\\?id=%2Fdummies%2F8$"},
              "@type": {"pattern": "^hydra:PartialCollectionView$"}
            }
          },
          "hydra:search": {}
        },
        "additionalProperties": false
      }
      """

--- Failed scenarios:

    features/hydra/collection.feature:283

@soyuka
Copy link
Member

soyuka commented Apr 19, 2017

Fixed through #1063 thanks @nik-lampe for investigating/testing!

@soyuka soyuka closed this Apr 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants