diff --git a/features/graphql/input_output.feature b/features/graphql/input_output.feature index 7956bf731e4..6dad98666d4 100644 --- a/features/graphql/input_output.feature +++ b/features/graphql/input_output.feature @@ -16,7 +16,7 @@ Feature: GraphQL DTO input and output } """ Then the response status code should be 201 - And the JSON should be equal to: + And the JSON should be a superset of: """ { "@context": { @@ -43,6 +43,7 @@ Feature: GraphQL DTO input and output "relatedToDummyFriend": [], "dummyBoolean": null, "embeddedDummy": { + "@type": "EmbeddableDummy", "dummyName": null, "dummyBoolean": null, "dummyDate": null, diff --git a/features/jsonld/non_resource.feature b/features/jsonld/non_resource.feature index 003124def81..29ef9c0b59d 100644 --- a/features/jsonld/non_resource.feature +++ b/features/jsonld/non_resource.feature @@ -12,7 +12,7 @@ Feature: JSON-LD non-resource handling Then the response status code should be 200 And the response should be in JSON And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8" - And the JSON should be equal to: + And the JSON should be a superset of: """ { "@context": "/contexts/ContainNonResource", @@ -25,11 +25,13 @@ Feature: JSON-LD non-resource handling "id": "1-nested", "nested": null, "notAResource": { + "@type": "NotAResource", "foo": "f2", "bar": "b2" } }, "notAResource": { + "@type": "NotAResource", "foo": "f1", "bar": "b1" } @@ -50,13 +52,14 @@ Feature: JSON-LD non-resource handling Then the response status code should be 201 And the response should be in JSON And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8" - And the JSON should be equal to: + And the JSON should be a superset of: """ { "@context": "/contexts/NonRelationResource", "@id": "/non_relation_resources/1", "@type": "NonRelationResource", "relation": { + "@type": "NonResourceClass", "foo": "test" }, "id": 1 diff --git a/features/main/operation.feature b/features/main/operation.feature index 8c70d1c2b99..1c26db087c7 100644 --- a/features/main/operation.feature +++ b/features/main/operation.feature @@ -43,16 +43,17 @@ Feature: Operation support Then the response status code should be 200 And the response should be in JSON And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8" - And the JSON should be equal to: + And the JSON should be a superset of: """ { - "@context": "/contexts/EmbeddedDummy", - "@id": "/embedded_dummies/1", - "@type": "EmbeddedDummy", - "name": "Dummy #1", - "embeddedDummy": { - "dummyName": "Dummy #1" - } + "@context": "/contexts/EmbeddedDummy", + "@id": "/embedded_dummies/1", + "@type": "EmbeddedDummy", + "name": "Dummy #1", + "embeddedDummy": { + "@type": "EmbeddableDummy", + "dummyName": "Dummy #1" + } } """ diff --git a/features/main/relation.feature b/features/main/relation.feature index fa3fe30c50a..8c268ed8417 100644 --- a/features/main/relation.feature +++ b/features/main/relation.feature @@ -402,7 +402,7 @@ Feature: Relations support And I send a "GET" request to "/people" Then the response status code should be 200 And the response should be in JSON - And the JSON should be equal to: + And the JSON should be a superset of: """ { "@context": "/contexts/Person", @@ -415,6 +415,7 @@ Feature: Relations support "name": "foo", "pets": [ { + "@type": "PersonToPet", "pet": { "@id": "/pets/1", "@type": "Pet", diff --git a/features/serializer/deserialize_objects_using_constructor.feature b/features/serializer/deserialize_objects_using_constructor.feature index 85c99c6b44e..24e5f20af96 100644 --- a/features/serializer/deserialize_objects_using_constructor.feature +++ b/features/serializer/deserialize_objects_using_constructor.feature @@ -21,7 +21,7 @@ Feature: Resource with constructor deserializable Then the response status code should be 201 And the response should be in JSON And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8" - And the JSON should be equal to: + And the JSON should be a superset of: """ { "@context": "/contexts/DummyEntityWithConstructor", @@ -32,6 +32,7 @@ Feature: Resource with constructor deserializable "bar": "world", "items": [ { + "@type": "DummyObjectWithoutConstructor", "foo": "bar" } ], diff --git a/src/JsonLd/Serializer/ObjectNormalizer.php b/src/JsonLd/Serializer/ObjectNormalizer.php index b45680e1546..308cda9035e 100644 --- a/src/JsonLd/Serializer/ObjectNormalizer.php +++ b/src/JsonLd/Serializer/ObjectNormalizer.php @@ -79,7 +79,7 @@ public function normalize($object, $format = null, array $context = []) $context['api_empty_resource_as_iri'] = true; $data = $this->decorated->normalize($object, $format, $context); - if (!\is_array($data)) { + if (!\is_array($data) || !$data) { return $data; }