diff --git a/src/Bridge/Symfony/Routing/ApiLoader.php b/src/Bridge/Symfony/Routing/ApiLoader.php index f414e0d8de4..991787712ec 100644 --- a/src/Bridge/Symfony/Routing/ApiLoader.php +++ b/src/Bridge/Symfony/Routing/ApiLoader.php @@ -123,8 +123,8 @@ public function load($data, $type = null): RouteCollection '_controller' => $controller, '_format' => null, '_api_resource_class' => $operation['resource_class'], - '_api_input_resource_class' => $operation['input_class'], - '_api_output_resource_class' => $operation['output_class'], + '_api_input_class' => $operation['input_class'], + '_api_output_class' => $operation['output_class'], '_api_subresource_operation_name' => $operation['route_name'], '_api_subresource_context' => [ 'property' => $operation['property'], @@ -212,8 +212,8 @@ private function addRoute(RouteCollection $routeCollection, string $resourceClas '_controller' => $controller, '_format' => null, '_api_resource_class' => $resourceClass, - '_api_input_resource_class' => $resourceMetadata->getAttribute('input_class', $resourceClass), - '_api_output_resource_class' => $resourceMetadata->getAttribute('output_class', $resourceClass), + '_api_input_class' => $resourceMetadata->getAttribute('input_class', $resourceClass), + '_api_output_class' => $resourceMetadata->getAttribute('output_class', $resourceClass), sprintf('_api_%s_operation_name', $operationType) => $operationName, ] + ($operation['defaults'] ?? []), $operation['requirements'] ?? [], diff --git a/src/DataProvider/OperationDataProviderTrait.php b/src/DataProvider/OperationDataProviderTrait.php index a24037592ab..5c9f31e903d 100644 --- a/src/DataProvider/OperationDataProviderTrait.php +++ b/src/DataProvider/OperationDataProviderTrait.php @@ -49,7 +49,7 @@ trait OperationDataProviderTrait */ private function getCollectionData(array $attributes, array $context) { - return $this->collectionDataProvider->getCollection($attributes['output_resource_class'], $attributes['collection_operation_name'], $context); + return $this->collectionDataProvider->getCollection($attributes['output_class'], $attributes['collection_operation_name'], $context); } /** @@ -59,7 +59,7 @@ private function getCollectionData(array $attributes, array $context) */ private function getItemData($identifiers, array $attributes, array $context) { - return $this->itemDataProvider->getItem($attributes['output_resource_class'], $identifiers, $attributes['item_operation_name'], $context); + return $this->itemDataProvider->getItem($attributes['output_class'], $identifiers, $attributes['item_operation_name'], $context); } /** @@ -75,7 +75,7 @@ private function getSubresourceData($identifiers, array $attributes, array $cont throw new RuntimeException('Subresources not supported'); } - return $this->subresourceDataProvider->getSubresource($attributes['output_resource_class'], $identifiers, $attributes['subresource_context'] + $context, $attributes['subresource_operation_name']); + return $this->subresourceDataProvider->getSubresource($attributes['output_class'], $identifiers, $attributes['subresource_context'] + $context, $attributes['subresource_operation_name']); } /** @@ -93,7 +93,7 @@ private function extractIdentifiers(array $parameters, array $attributes) $id = $parameters['id']; if (null !== $this->identifierConverter) { - return $this->identifierConverter->convert((string) $id, $attributes['output_resource_class']); + return $this->identifierConverter->convert((string) $id, $attributes['output_class']); } return $id; diff --git a/src/EventListener/DeserializeListener.php b/src/EventListener/DeserializeListener.php index 2b821887ce8..d977823eed1 100644 --- a/src/EventListener/DeserializeListener.php +++ b/src/EventListener/DeserializeListener.php @@ -81,6 +81,9 @@ public function onKernelRequest(GetResponseEvent $event) $format = $this->getFormat($request); $context = $this->serializerContextBuilder->createFromRequest($request, false, $attributes); + if (isset($context['input_class'])) { + $context['resource_class'] = $context['input_class']; + } $data = $request->attributes->get('data'); if (null !== $data) { @@ -90,7 +93,7 @@ public function onKernelRequest(GetResponseEvent $event) $request->attributes->set( 'data', $this->serializer->deserialize( - $requestContent, $attributes['input_resource_class'], $format, $context + $requestContent, $attributes['input_class'], $format, $context ) ); } diff --git a/src/EventListener/SerializeListener.php b/src/EventListener/SerializeListener.php index 80e3b0602a7..3f47a476208 100644 --- a/src/EventListener/SerializeListener.php +++ b/src/EventListener/SerializeListener.php @@ -63,6 +63,10 @@ public function onKernelView(GetResponseForControllerResultEvent $event) } $resources = new ResourceList(); $context['resources'] = &$resources; + if (isset($context['output_class'])) { + $context['resource_class'] = $context['output_class']; + } + $request->attributes->set('_api_normalization_context', $context); $event->setControllerResult($this->serializer->serialize($controllerResult, $request->getRequestFormat(), $context)); diff --git a/src/Serializer/AbstractItemNormalizer.php b/src/Serializer/AbstractItemNormalizer.php index 4c9c4a8217d..9091a13147e 100644 --- a/src/Serializer/AbstractItemNormalizer.php +++ b/src/Serializer/AbstractItemNormalizer.php @@ -96,10 +96,6 @@ public function hasCacheableSupportsMethod(): bool */ public function normalize($object, $format = null, array $context = []) { - if (isset($context['resource_class']) && isset($context['normalize_resource_class'])) { - $context['resource_class'] = $context['normalize_resource_class']; - } - $resourceClass = $this->resourceClassResolver->getResourceClass($object, $context['resource_class'] ?? null, true); $context = $this->initContext($resourceClass, $context); $context['api_normalize'] = true; @@ -128,10 +124,6 @@ public function denormalize($data, $class, $format = null, array $context = []) $context['api_denormalize'] = true; if (!isset($context['resource_class'])) { $context['resource_class'] = $class; - - if (isset($context['denormalize_resource_class'])) { - $context['resource_class'] = $context['denormalize_resource_class']; - } } return parent::denormalize($data, $class, $format, $context); diff --git a/src/Serializer/SerializerContextBuilder.php b/src/Serializer/SerializerContextBuilder.php index 01bdf7da2c0..28267939d78 100644 --- a/src/Serializer/SerializerContextBuilder.php +++ b/src/Serializer/SerializerContextBuilder.php @@ -73,8 +73,8 @@ public function createFromRequest(Request $request, bool $normalization, array $ } $context['resource_class'] = $attributes['resource_class']; - $context['denormalize_resource_class'] = $attributes['input_resource_class'] ?? $attributes['resource_class']; - $context['normalize_resource_class'] = $attributes['output_resource_class'] ?? $attributes['resource_class']; + $context['input_class'] = $attributes['input_class'] ?? $attributes['resource_class']; + $context['output_class'] = $attributes['output_class'] ?? $attributes['resource_class']; $context['request_uri'] = $request->getRequestUri(); $context['uri'] = $request->getUri(); diff --git a/src/Util/AttributesExtractor.php b/src/Util/AttributesExtractor.php index f9a0f37f1f7..da8f6e2742e 100644 --- a/src/Util/AttributesExtractor.php +++ b/src/Util/AttributesExtractor.php @@ -35,9 +35,8 @@ private function __construct() public static function extractAttributes(array $attributes): array { $result = ['resource_class' => $attributes['_api_resource_class'] ?? null]; - - $result['input_resource_class'] = $attributes['_api_input_resource_class'] ?? $result['resource_class']; - $result['output_resource_class'] = $attributes['_api_output_resource_class'] ?? $result['resource_class']; + $result['input_class'] = $attributes['_api_input_class'] ?? $result['resource_class']; + $result['output_class'] = $attributes['_api_output_class'] ?? $result['resource_class']; if ($subresourceContext = $attributes['_api_subresource_context'] ?? null) { $result['subresource_context'] = $subresourceContext; diff --git a/tests/Bridge/Symfony/Bundle/DataCollector/RequestDataCollectorTest.php b/tests/Bridge/Symfony/Bundle/DataCollector/RequestDataCollectorTest.php index a2b3d08ba48..5056d418f7a 100644 --- a/tests/Bridge/Symfony/Bundle/DataCollector/RequestDataCollectorTest.php +++ b/tests/Bridge/Symfony/Bundle/DataCollector/RequestDataCollectorTest.php @@ -107,7 +107,7 @@ public function testWithResource() $this->response ); - $this->assertSame(['resource_class' => DummyEntity::class, 'input_resource_class' => DummyEntity::class, 'output_resource_class' => DummyEntity::class, 'item_operation_name' => 'get', 'receive' => true, 'persist' => true], $dataCollector->getRequestAttributes()); + $this->assertSame(['resource_class' => DummyEntity::class, 'input_class' => DummyEntity::class, 'output_class' => DummyEntity::class, 'item_operation_name' => 'get', 'receive' => true, 'persist' => true], $dataCollector->getRequestAttributes()); $this->assertSame(['foo', 'bar'], $dataCollector->getAcceptableContentTypes()); $this->assertSame(DummyEntity::class, $dataCollector->getResourceClass()); $this->assertSame(['foo' => null, 'a_filter' => \stdClass::class], $dataCollector->getFilters()); diff --git a/tests/Bridge/Symfony/Routing/ApiLoaderTest.php b/tests/Bridge/Symfony/Routing/ApiLoaderTest.php index a65158140a9..ec9ecf162c9 100644 --- a/tests/Bridge/Symfony/Routing/ApiLoaderTest.php +++ b/tests/Bridge/Symfony/Routing/ApiLoaderTest.php @@ -305,8 +305,8 @@ private function getRoute(string $path, string $controller, string $resourceClas '_controller' => $controller, '_format' => null, '_api_resource_class' => $resourceClass, - '_api_input_resource_class' => $resourceClass, - '_api_output_resource_class' => $resourceClass, + '_api_input_class' => $resourceClass, + '_api_output_class' => $resourceClass, sprintf('_api_%s_operation_name', $collection ? 'collection' : 'item') => $operationName, ] + $extraDefaults, $requirements, @@ -326,8 +326,8 @@ private function getSubresourceRoute(string $path, string $controller, string $r '_controller' => $controller, '_format' => null, '_api_resource_class' => $resourceClass, - '_api_input_resource_class' => $resourceClass, - '_api_output_resource_class' => $resourceClass, + '_api_input_class' => $resourceClass, + '_api_output_class' => $resourceClass, '_api_subresource_operation_name' => $operationName, '_api_subresource_context' => $context, ], diff --git a/tests/EventListener/AddFormatListenerTest.php b/tests/EventListener/AddFormatListenerTest.php index ed833eb81af..014597a3f16 100644 --- a/tests/EventListener/AddFormatListenerTest.php +++ b/tests/EventListener/AddFormatListenerTest.php @@ -224,7 +224,7 @@ public function testResourceClassSupportedRequestFormat() $event = $eventProphecy->reveal(); $formatsProviderProphecy = $this->prophesize(FormatsProviderInterface::class); - $formatsProviderProphecy->getFormatsFromAttributes(['resource_class' => 'Foo', 'input_resource_class' => 'Foo', 'output_resource_class' => 'Foo', 'collection_operation_name' => 'get', 'receive' => true, 'persist' => true])->willReturn(['csv' => ['text/csv']])->shouldBeCalled(); + $formatsProviderProphecy->getFormatsFromAttributes(['resource_class' => 'Foo', 'input_class' => 'Foo', 'output_class' => 'Foo', 'collection_operation_name' => 'get', 'receive' => true, 'persist' => true])->willReturn(['csv' => ['text/csv']])->shouldBeCalled(); $listener = new AddFormatListener(new Negotiator(), $formatsProviderProphecy->reveal()); $listener->onKernelRequest($event); diff --git a/tests/EventListener/DeserializeListenerTest.php b/tests/EventListener/DeserializeListenerTest.php index 3d73e168307..24e2876280b 100644 --- a/tests/EventListener/DeserializeListenerTest.php +++ b/tests/EventListener/DeserializeListenerTest.php @@ -172,7 +172,7 @@ public function testDeserializeResourceClassSupportedFormat(string $method, bool $serializerContextBuilderProphecy->createFromRequest(Argument::type(Request::class), false, Argument::type('array'))->willReturn([])->shouldBeCalled(); $formatsProviderProphecy = $this->prophesize(FormatsProviderInterface::class); - $formatsProviderProphecy->getFormatsFromAttributes(['resource_class' => 'Foo', 'input_resource_class' => 'Foo', 'output_resource_class' => 'Foo', 'collection_operation_name' => 'post', 'receive' => true, 'persist' => true])->willReturn(self::FORMATS)->shouldBeCalled(); + $formatsProviderProphecy->getFormatsFromAttributes(['resource_class' => 'Foo', 'input_class' => 'Foo', 'output_class' => 'Foo', 'collection_operation_name' => 'post', 'receive' => true, 'persist' => true])->willReturn(self::FORMATS)->shouldBeCalled(); $listener = new DeserializeListener($serializerProphecy->reveal(), $serializerContextBuilderProphecy->reveal(), $formatsProviderProphecy->reveal()); diff --git a/tests/Serializer/SerializerContextBuilderTest.php b/tests/Serializer/SerializerContextBuilderTest.php index 612ef1f5918..08f539522c7 100644 --- a/tests/Serializer/SerializerContextBuilderTest.php +++ b/tests/Serializer/SerializerContextBuilderTest.php @@ -55,32 +55,32 @@ public function testCreateFromRequest() { $request = Request::create('/foos/1'); $request->attributes->replace(['_api_resource_class' => 'Foo', '_api_item_operation_name' => 'get', '_api_format' => 'xml', '_api_mime_type' => 'text/xml']); - $expected = ['foo' => 'bar', 'item_operation_name' => 'get', 'resource_class' => 'Foo', 'request_uri' => '/foos/1', 'operation_type' => 'item', 'uri' => 'http://localhost/foos/1', 'denormalize_resource_class' => 'Foo', 'normalize_resource_class' => 'Foo']; + $expected = ['foo' => 'bar', 'item_operation_name' => 'get', 'resource_class' => 'Foo', 'request_uri' => '/foos/1', 'operation_type' => 'item', 'uri' => 'http://localhost/foos/1', 'output_class' => 'Foo', 'input_class' => 'Foo']; $this->assertEquals($expected, $this->builder->createFromRequest($request, true)); $request = Request::create('/foos'); $request->attributes->replace(['_api_resource_class' => 'Foo', '_api_collection_operation_name' => 'pot', '_api_format' => 'xml', '_api_mime_type' => 'text/xml']); - $expected = ['foo' => 'bar', 'collection_operation_name' => 'pot', 'resource_class' => 'Foo', 'request_uri' => '/foos', 'operation_type' => 'collection', 'uri' => 'http://localhost/foos', 'denormalize_resource_class' => 'Foo', 'normalize_resource_class' => 'Foo']; + $expected = ['foo' => 'bar', 'collection_operation_name' => 'pot', 'resource_class' => 'Foo', 'request_uri' => '/foos', 'operation_type' => 'collection', 'uri' => 'http://localhost/foos', 'output_class' => 'Foo', 'input_class' => 'Foo']; $this->assertEquals($expected, $this->builder->createFromRequest($request, true)); $request = Request::create('/foos/1'); $request->attributes->replace(['_api_resource_class' => 'Foo', '_api_item_operation_name' => 'get', '_api_format' => 'xml', '_api_mime_type' => 'text/xml']); - $expected = ['bar' => 'baz', 'item_operation_name' => 'get', 'resource_class' => 'Foo', 'request_uri' => '/foos/1', 'api_allow_update' => false, 'operation_type' => 'item', 'uri' => 'http://localhost/foos/1', 'denormalize_resource_class' => 'Foo', 'normalize_resource_class' => 'Foo']; + $expected = ['bar' => 'baz', 'item_operation_name' => 'get', 'resource_class' => 'Foo', 'request_uri' => '/foos/1', 'api_allow_update' => false, 'operation_type' => 'item', 'uri' => 'http://localhost/foos/1', 'output_class' => 'Foo', 'input_class' => 'Foo']; $this->assertEquals($expected, $this->builder->createFromRequest($request, false)); $request = Request::create('/foos', 'POST'); $request->attributes->replace(['_api_resource_class' => 'Foo', '_api_collection_operation_name' => 'post', '_api_format' => 'xml', '_api_mime_type' => 'text/xml']); - $expected = ['bar' => 'baz', 'collection_operation_name' => 'post', 'resource_class' => 'Foo', 'request_uri' => '/foos', 'api_allow_update' => false, 'operation_type' => 'collection', 'uri' => 'http://localhost/foos', 'denormalize_resource_class' => 'Foo', 'normalize_resource_class' => 'Foo']; + $expected = ['bar' => 'baz', 'collection_operation_name' => 'post', 'resource_class' => 'Foo', 'request_uri' => '/foos', 'api_allow_update' => false, 'operation_type' => 'collection', 'uri' => 'http://localhost/foos', 'output_class' => 'Foo', 'input_class' => 'Foo']; $this->assertEquals($expected, $this->builder->createFromRequest($request, false)); $request = Request::create('/foos', 'PUT'); $request->attributes->replace(['_api_resource_class' => 'Foo', '_api_collection_operation_name' => 'put', '_api_format' => 'xml', '_api_mime_type' => 'text/xml']); - $expected = ['bar' => 'baz', 'collection_operation_name' => 'put', 'resource_class' => 'Foo', 'request_uri' => '/foos', 'api_allow_update' => true, 'operation_type' => 'collection', 'uri' => 'http://localhost/foos', 'denormalize_resource_class' => 'Foo', 'normalize_resource_class' => 'Foo']; + $expected = ['bar' => 'baz', 'collection_operation_name' => 'put', 'resource_class' => 'Foo', 'request_uri' => '/foos', 'api_allow_update' => true, 'operation_type' => 'collection', 'uri' => 'http://localhost/foos', 'output_class' => 'Foo', 'input_class' => 'Foo']; $this->assertEquals($expected, $this->builder->createFromRequest($request, false)); $request = Request::create('/bars/1/foos'); $request->attributes->replace(['_api_resource_class' => 'Foo', '_api_subresource_operation_name' => 'get', '_api_format' => 'xml', '_api_mime_type' => 'text/xml']); - $expected = ['bar' => 'baz', 'subresource_operation_name' => 'get', 'resource_class' => 'Foo', 'request_uri' => '/bars/1/foos', 'operation_type' => 'subresource', 'api_allow_update' => false, 'uri' => 'http://localhost/bars/1/foos', 'denormalize_resource_class' => 'Foo', 'normalize_resource_class' => 'Foo']; + $expected = ['bar' => 'baz', 'subresource_operation_name' => 'get', 'resource_class' => 'Foo', 'request_uri' => '/bars/1/foos', 'operation_type' => 'subresource', 'api_allow_update' => false, 'uri' => 'http://localhost/bars/1/foos', 'output_class' => 'Foo', 'input_class' => 'Foo']; $this->assertEquals($expected, $this->builder->createFromRequest($request, false)); } @@ -93,7 +93,7 @@ public function testThrowExceptionOnInvalidRequest() public function testReuseExistingAttributes() { - $expected = ['bar' => 'baz', 'item_operation_name' => 'get', 'resource_class' => 'Foo', 'request_uri' => '/foos/1', 'api_allow_update' => false, 'operation_type' => 'item', 'uri' => 'http://localhost/foos/1', 'denormalize_resource_class' => 'Foo', 'normalize_resource_class' => 'Foo']; + $expected = ['bar' => 'baz', 'item_operation_name' => 'get', 'resource_class' => 'Foo', 'request_uri' => '/foos/1', 'api_allow_update' => false, 'operation_type' => 'item', 'uri' => 'http://localhost/foos/1', 'output_class' => 'Foo', 'input_class' => 'Foo']; $this->assertEquals($expected, $this->builder->createFromRequest(Request::create('/foos/1'), false, ['resource_class' => 'Foo', 'item_operation_name' => 'get'])); } } diff --git a/tests/Serializer/SerializerFilterContextBuilderTest.php b/tests/Serializer/SerializerFilterContextBuilderTest.php index fc57de6de19..6ff7d027f9d 100644 --- a/tests/Serializer/SerializerFilterContextBuilderTest.php +++ b/tests/Serializer/SerializerFilterContextBuilderTest.php @@ -36,8 +36,8 @@ public function testCreateFromRequestWithCollectionOperation() $attributes = [ 'resource_class' => DummyGroup::class, - 'input_resource_class' => DummyGroup::class, - 'output_resource_class' => DummyGroup::class, + 'input_class' => DummyGroup::class, + 'output_class' => DummyGroup::class, 'collection_operation_name' => 'get', ]; @@ -79,8 +79,8 @@ public function testCreateFromRequestWithItemOperation() $attributes = [ 'resource_class' => DummyGroup::class, - 'input_resource_class' => DummyGroup::class, - 'output_resource_class' => DummyGroup::class, + 'input_class' => DummyGroup::class, + 'output_class' => DummyGroup::class, 'item_operation_name' => 'put', ]; @@ -122,8 +122,8 @@ public function testCreateFromRequestWithoutFilters() $attributes = [ 'resource_class' => DummyGroup::class, - 'input_resource_class' => DummyGroup::class, - 'output_resource_class' => DummyGroup::class, + 'input_class' => DummyGroup::class, + 'output_class' => DummyGroup::class, 'collection_operation_name' => 'get', ]; @@ -158,8 +158,8 @@ public function testCreateFromRequestWithoutAttributes() $attributes = [ 'resource_class' => DummyGroup::class, - 'input_resource_class' => DummyGroup::class, - 'output_resource_class' => DummyGroup::class, + 'input_class' => DummyGroup::class, + 'output_class' => DummyGroup::class, 'collection_operation_name' => 'get', 'receive' => true, 'persist' => true, diff --git a/tests/Util/RequestAttributesExtractorTest.php b/tests/Util/RequestAttributesExtractorTest.php index 589526dd434..f383585ed74 100644 --- a/tests/Util/RequestAttributesExtractorTest.php +++ b/tests/Util/RequestAttributesExtractorTest.php @@ -30,8 +30,8 @@ public function testExtractCollectionAttributes() [ 'resource_class' => 'Foo', 'collection_operation_name' => 'post', - 'input_resource_class' => 'Foo', - 'output_resource_class' => 'Foo', + 'input_class' => 'Foo', + 'output_class' => 'Foo', 'receive' => true, 'persist' => true, ], @@ -47,8 +47,8 @@ public function testExtractItemAttributes() [ 'resource_class' => 'Foo', 'item_operation_name' => 'get', - 'input_resource_class' => 'Foo', - 'output_resource_class' => 'Foo', + 'input_class' => 'Foo', + 'output_class' => 'Foo', 'receive' => true, 'persist' => true, ], @@ -64,8 +64,8 @@ public function testExtractReceive() [ 'resource_class' => 'Foo', 'item_operation_name' => 'get', - 'input_resource_class' => 'Foo', - 'output_resource_class' => 'Foo', + 'input_class' => 'Foo', + 'output_class' => 'Foo', 'receive' => false, 'persist' => true, ], @@ -78,8 +78,8 @@ public function testExtractReceive() [ 'resource_class' => 'Foo', 'item_operation_name' => 'get', - 'input_resource_class' => 'Foo', - 'output_resource_class' => 'Foo', + 'input_class' => 'Foo', + 'output_class' => 'Foo', 'receive' => true, 'persist' => true, ], @@ -91,8 +91,8 @@ public function testExtractReceive() $this->assertEquals( [ 'resource_class' => 'Foo', - 'input_resource_class' => 'Foo', - 'output_resource_class' => 'Foo', + 'input_class' => 'Foo', + 'output_class' => 'Foo', 'item_operation_name' => 'get', 'receive' => true, 'persist' => true, @@ -108,8 +108,8 @@ public function testExtractPersist() $this->assertEquals( [ 'resource_class' => 'Foo', - 'input_resource_class' => 'Foo', - 'output_resource_class' => 'Foo', + 'input_class' => 'Foo', + 'output_class' => 'Foo', 'item_operation_name' => 'get', 'receive' => true, 'persist' => false, @@ -122,8 +122,8 @@ public function testExtractPersist() $this->assertEquals( [ 'resource_class' => 'Foo', - 'input_resource_class' => 'Foo', - 'output_resource_class' => 'Foo', + 'input_class' => 'Foo', + 'output_class' => 'Foo', 'item_operation_name' => 'get', 'receive' => true, 'persist' => true, @@ -136,8 +136,8 @@ public function testExtractPersist() $this->assertEquals( [ 'resource_class' => 'Foo', - 'input_resource_class' => 'Foo', - 'output_resource_class' => 'Foo', + 'input_class' => 'Foo', + 'output_class' => 'Foo', 'item_operation_name' => 'get', 'receive' => true, 'persist' => true, @@ -148,28 +148,28 @@ public function testExtractPersist() public function testExtractInputOutputResourceClass() { - $request = new Request([], [], ['_api_resource_class' => 'Foo', '_api_item_operation_name' => 'get', '_api_input_resource_class' => 'Bar']); + $request = new Request([], [], ['_api_resource_class' => 'Foo', '_api_item_operation_name' => 'get', '_api_input_class' => 'Bar']); $this->assertEquals( [ 'resource_class' => 'Foo', 'item_operation_name' => 'get', - 'input_resource_class' => 'Bar', - 'output_resource_class' => 'Foo', + 'input_class' => 'Bar', + 'output_class' => 'Foo', 'receive' => true, 'persist' => true, ], RequestAttributesExtractor::extractAttributes($request) ); - $request = new Request([], [], ['_api_resource_class' => 'Foo', '_api_item_operation_name' => 'get', '_api_output_resource_class' => 'Bar']); + $request = new Request([], [], ['_api_resource_class' => 'Foo', '_api_item_operation_name' => 'get', '_api_output_class' => 'Bar']); $this->assertEquals( [ 'resource_class' => 'Foo', 'item_operation_name' => 'get', - 'input_resource_class' => 'Foo', - 'output_resource_class' => 'Bar', + 'input_class' => 'Foo', + 'output_class' => 'Bar', 'receive' => true, 'persist' => true, ], @@ -179,16 +179,16 @@ public function testExtractInputOutputResourceClass() $request = new Request([], [], [ '_api_resource_class' => 'Foo', '_api_item_operation_name' => 'get', - '_api_input_resource_class' => 'FooBar', - '_api_output_resource_class' => 'Bar', + '_api_input_class' => 'FooBar', + '_api_output_class' => 'Bar', ]); $this->assertEquals( [ 'resource_class' => 'Foo', 'item_operation_name' => 'get', - 'input_resource_class' => 'FooBar', - 'output_resource_class' => 'Bar', + 'input_class' => 'FooBar', + 'output_class' => 'Bar', 'receive' => true, 'persist' => true, ],