From 0ed839f7116dee296770ba9dd7510467747e9c3b Mon Sep 17 00:00:00 2001 From: jld3103 Date: Fri, 8 Dec 2023 09:32:30 +0100 Subject: [PATCH] feat: Use path parameter defaults from routes Signed-off-by: jld3103 --- generate-spec | 6 ++++++ src/Route.php | 1 + 2 files changed, 7 insertions(+) diff --git a/generate-spec b/generate-spec index 8b7eb31..094da3a 100755 --- a/generate-spec +++ b/generate-spec @@ -239,6 +239,7 @@ foreach ($parsedRoutes as $key => $value) { $postfix = array_key_exists("postfix", $route) ? $route["postfix"] : null; $verb = array_key_exists("verb", $route) ? $route["verb"] : "GET"; $requirements = array_key_exists("requirements", $route) ? $route["requirements"] : []; + $defaults = array_key_exists("defaults", $route) ? $route["defaults"] : []; $root = array_key_exists("root", $route) ? $route["root"] : ($appIsCore ? "" : "/apps/" . $appID); $url = $route["url"]; if (!str_starts_with($url, "/")) { @@ -387,6 +388,7 @@ foreach ($parsedRoutes as $key => $value) { $verb, $url, $requirements, + $defaults, $classMethodInfo, $isOCS, $isCORS, @@ -464,6 +466,10 @@ foreach ($routes as $route) { } } + if (array_key_exists($urlParameter, $route->defaults)) { + $schema["default"] = $route->defaults[$urlParameter]; + } + $pathParameters[] = array_merge( [ "name" => $urlParameter, diff --git a/src/Route.php b/src/Route.php index 3c7117f..a181061 100644 --- a/src/Route.php +++ b/src/Route.php @@ -12,6 +12,7 @@ public function __construct( public string $verb, public string $url, public array $requirements, + public array $defaults, public ControllerMethod $controllerMethod, public bool $isOCS, public bool $isCORS,