diff --git a/src/Appwrite/SDK/Specification/Format/OpenAPI3.php b/src/Appwrite/SDK/Specification/Format/OpenAPI3.php index 004be99c5b..4f925b1811 100644 --- a/src/Appwrite/SDK/Specification/Format/OpenAPI3.php +++ b/src/Appwrite/SDK/Specification/Format/OpenAPI3.php @@ -756,19 +756,13 @@ class OpenAPI3 extends Format } $pathAliases = [$name, ...($param['aliases'] ?? [])]; + $pathAliasMap = \array_flip($pathAliases); $isPathParam = false; - foreach ($pathAliases as $pathAlias) { - $pathNeedle = ':' . $pathAlias; - $offset = 0; - while (false !== ($position = \strpos($url, $pathNeedle, $offset))) { - $nextChar = $url[$position + \strlen($pathNeedle)] ?? ''; - if ($nextChar === '' || $nextChar === '/') { - $isPathParam = true; - break 2; - } - - $offset = $position + 1; + foreach (\explode('/', $url) as $segment) { + if ($segment !== '' && $segment[0] === ':' && isset($pathAliasMap[\substr($segment, 1)])) { + $isPathParam = true; + break; } } diff --git a/src/Appwrite/SDK/Specification/Format/Swagger2.php b/src/Appwrite/SDK/Specification/Format/Swagger2.php index 2d7965df6a..c352154006 100644 --- a/src/Appwrite/SDK/Specification/Format/Swagger2.php +++ b/src/Appwrite/SDK/Specification/Format/Swagger2.php @@ -723,19 +723,13 @@ class Swagger2 extends Format } $pathAliases = [$name, ...($param['aliases'] ?? [])]; + $pathAliasMap = \array_flip($pathAliases); $isPathParam = false; - foreach ($pathAliases as $pathAlias) { - $pathNeedle = ':' . $pathAlias; - $offset = 0; - while (false !== ($position = \strpos($url, $pathNeedle, $offset))) { - $nextChar = $url[$position + \strlen($pathNeedle)] ?? ''; - if ($nextChar === '' || $nextChar === '/') { - $isPathParam = true; - break 2; - } - - $offset = $position + 1; + foreach (\explode('/', $url) as $segment) { + if ($segment !== '' && $segment[0] === ':' && isset($pathAliasMap[\substr($segment, 1)])) { + $isPathParam = true; + break; } }