Skip to content

Commit

Permalink
BUGFIX: DocumentFactory will ignore unknown http methods instead of t…
Browse files Browse the repository at this point in the history
…hrowing errors

This us useful for routes that implement methods like OPTION for cors.
  • Loading branch information
mficzel committed Jun 19, 2024
1 parent 68df7c8 commit 4c87ff3
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 4c87ff3

Please sign in to comment.