diff --git a/composer.json b/composer.json index 228872a2b1d..c1416a74654 100644 --- a/composer.json +++ b/composer.json @@ -17,6 +17,7 @@ "doctrine/inflector": "^1.0", "psr/cache": "^1.0", "psr/container": "^1.0", + "symfony/config": "^2.0 || ^3.0 || ^4.0", "symfony/http-foundation": "^3.4 || ^4.0", "symfony/http-kernel": "^3.4 || ^4.0", "symfony/property-access": "^3.4 || ^4.0", diff --git a/src/Metadata/Resource/Factory/OperationResourceMetadataFactory.php b/src/Metadata/Resource/Factory/OperationResourceMetadataFactory.php index 4db5f5045d5..6ddb0cce174 100644 --- a/src/Metadata/Resource/Factory/OperationResourceMetadataFactory.php +++ b/src/Metadata/Resource/Factory/OperationResourceMetadataFactory.php @@ -14,6 +14,7 @@ namespace ApiPlatform\Core\Metadata\Resource\Factory; use ApiPlatform\Core\Metadata\Resource\ResourceMetadata; +use Symfony\Component\Config\Exception\LoaderLoadException; /** * Creates or completes operations. @@ -123,6 +124,13 @@ private function normalize(bool $collection, ResourceMetadata $resourceMetadata, $supported ? $operation['method'] = $upperOperationName : $operation['route_name'] = $operationName; } + if (strtoupper($operation['method']) !== $operation['method']) { + $message = sprintf('The method "%s" of operation "%s" should be in uppercase.', $operation['method'], $operationName); + + // See DelegatingLoader::load to understand why we use a LoaderLoadException + throw new LoaderLoadException($resourceMetadata->getShortName(), 'api-platform', null, new \InvalidArgumentException($message)); + } + $newOperations[$operationName] = $operation; }