Skip to content

Commit f5ea1e1

Browse files
committed
replace swagger with OpenApi in preparation for OpenApi v3
1 parent 1447c7a commit f5ea1e1

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"zircote/swagger-php": "^2.1"
2020
},
2121
"require-dev": {
22-
"symfony/phpunit-bridge": "^5.0@dev"
22+
"symfony/phpunit-bridge": "^5.2"
2323
},
2424
"autoload": {
2525
"psr-4": {

src/OpenApiRouteLoader.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,35 +44,35 @@ public static function fromSrcDirectory(): self
4444

4545
public function __invoke(): RouteCollection
4646
{
47-
$fullSwagger = \Swagger\scan($this->finder);
47+
$openApi = \Swagger\scan($this->finder);
4848
$routeCollection = new RouteCollection();
4949

50-
$globalFormatSuffixConfig = FormatSuffixConfig::fromAnnotation($fullSwagger);
50+
$globalFormatSuffixConfig = FormatSuffixConfig::fromAnnotation($openApi);
5151

52-
foreach ($fullSwagger->paths as $path) {
52+
foreach ($openApi->paths as $path) {
5353
$pathFormatSuffixConfig = FormatSuffixConfig::fromAnnotation($path, $globalFormatSuffixConfig);
5454

55-
$this->addRouteFromSwaggerOperation($routeCollection, $path->get, $pathFormatSuffixConfig);
56-
$this->addRouteFromSwaggerOperation($routeCollection, $path->put, $pathFormatSuffixConfig);
57-
$this->addRouteFromSwaggerOperation($routeCollection, $path->post, $pathFormatSuffixConfig);
58-
$this->addRouteFromSwaggerOperation($routeCollection, $path->delete, $pathFormatSuffixConfig);
59-
$this->addRouteFromSwaggerOperation($routeCollection, $path->options, $pathFormatSuffixConfig);
60-
$this->addRouteFromSwaggerOperation($routeCollection, $path->head, $pathFormatSuffixConfig);
61-
$this->addRouteFromSwaggerOperation($routeCollection, $path->patch, $pathFormatSuffixConfig);
55+
$this->addRouteFromOpenApiOperation($routeCollection, $path->get, $pathFormatSuffixConfig);
56+
$this->addRouteFromOpenApiOperation($routeCollection, $path->put, $pathFormatSuffixConfig);
57+
$this->addRouteFromOpenApiOperation($routeCollection, $path->post, $pathFormatSuffixConfig);
58+
$this->addRouteFromOpenApiOperation($routeCollection, $path->delete, $pathFormatSuffixConfig);
59+
$this->addRouteFromOpenApiOperation($routeCollection, $path->options, $pathFormatSuffixConfig);
60+
$this->addRouteFromOpenApiOperation($routeCollection, $path->head, $pathFormatSuffixConfig);
61+
$this->addRouteFromOpenApiOperation($routeCollection, $path->patch, $pathFormatSuffixConfig);
6262
}
6363

6464
$this->routeNames = [];
6565

6666
return $routeCollection;
6767
}
6868

69-
private function addRouteFromSwaggerOperation(RouteCollection $routeCollection, ?Operation $operation, FormatSuffixConfig $parentFormatSuffixConfig): void
69+
private function addRouteFromOpenApiOperation(RouteCollection $routeCollection, ?Operation $operation, FormatSuffixConfig $parentFormatSuffixConfig): void
7070
{
7171
if (null === $operation) {
7272
return;
7373
}
7474

75-
$controller = $this->getControllerFromSwaggerOperation($operation);
75+
$controller = $this->getControllerFromOpenApiOperation($operation);
7676
$name = $this->getRouteName($operation, $controller);
7777
$route = $this->createRoute($operation, $controller, $parentFormatSuffixConfig);
7878
$routeCollection->add($name, $route);
@@ -105,7 +105,7 @@ private function createRoute(Operation $operation, string $controller, FormatSuf
105105
return $route;
106106
}
107107

108-
private function getControllerFromSwaggerOperation(Operation $operation): string
108+
private function getControllerFromOpenApiOperation(Operation $operation): string
109109
{
110110
$classOrService = ltrim($operation->_context->fullyQualifiedName($operation->_context->class), '\\');
111111

0 commit comments

Comments
 (0)