forked from api-platform/core
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request api-platform#1192 from meyerbaptiste/fix_swagger_c…
…ustom_operation_path Fix path for custom operation with Swagger UI
- Loading branch information
Showing
18 changed files
with
404 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the API Platform project. | ||
* | ||
* (c) Kévin Dunglas <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ApiPlatform\Core\Bridge\Symfony\Routing; | ||
|
||
use ApiPlatform\Core\Api\OperationType; | ||
use ApiPlatform\Core\Api\OperationTypeDeprecationHelper; | ||
use ApiPlatform\Core\Exception\InvalidArgumentException; | ||
use Doctrine\Common\Util\Inflector; | ||
|
||
/** | ||
* Generates the Symfony route name associated with an operation name and a resource short name. | ||
* | ||
* @internal | ||
* | ||
* @author Baptiste Meyer <[email protected]> | ||
*/ | ||
class RouteNameGenerator | ||
{ | ||
const ROUTE_NAME_PREFIX = 'api_'; | ||
|
||
private function __construct() | ||
{ | ||
} | ||
|
||
/** | ||
* Generates a Symfony route name. | ||
* | ||
* @param string $operationName | ||
* @param string $resourceShortName | ||
* @param string|bool $operationType | ||
* | ||
* @throws InvalidArgumentException | ||
* | ||
* @return string | ||
*/ | ||
public static function generate(string $operationName, string $resourceShortName, $operationType): string | ||
{ | ||
if (OperationType::SUBRESOURCE === $operationType = OperationTypeDeprecationHelper::getOperationType($operationType)) { | ||
throw new InvalidArgumentException(sprintf('%s::SUBRESOURCE is not supported as operation type by %s().', OperationType::class, __METHOD__)); | ||
} | ||
|
||
return sprintf( | ||
'%s%s_%s_%s', | ||
static::ROUTE_NAME_PREFIX, | ||
Inflector::pluralize(Inflector::tableize($resourceShortName)), | ||
$operationName, | ||
$operationType | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.