Skip to content

Commit

Permalink
Added a protecting when someone is using a lower case method
Browse files Browse the repository at this point in the history
  • Loading branch information
lyrixx committed Apr 7, 2019
1 parent 44a686c commit b219add
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit b219add

Please sign in to comment.