Skip to content

Commit

Permalink
Merge pull request #21 from sitegeist/bugfix/documentFactoryIgnoresUn…
Browse files Browse the repository at this point in the history
…knownHttpMethods

BUGFIX: DocumentFactory will ignore unknown http methods instead of throwing errors
  • Loading branch information
mficzel authored Jun 19, 2024
2 parents 68df7c8 + 4c87ff3 commit cafa8fb
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions Classes/Domain/OpenApiDocumentFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,16 @@ private function createPathsFromPathAndMethodReflection(ClassReflection $classRe
$route->getUriPattern()
);
foreach ($route->getHttpMethods() as $httpMethod) {
$paths[] = new OpenApiPathItem(
new PathDefinition('/' . $path),
HttpMethod::from(strtolower($httpMethod)),
new OpenApiParameterCollection(...$parameters),
$requestBody,
OpenApiResponses::fromReflectionMethod($methodReflection)
);
$httpMethod = HttpMethod::tryFrom(strtolower($httpMethod));
if ($httpMethod instanceof HttpMethod) {
$paths[] = new OpenApiPathItem(
new PathDefinition('/' . $path),
$httpMethod,
new OpenApiParameterCollection(...$parameters),
$requestBody,
OpenApiResponses::fromReflectionMethod($methodReflection)
);
}
}
// only the first matching route is needed so we can break the loop here
break;
Expand Down

0 comments on commit cafa8fb

Please sign in to comment.