Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
feat: Use path parameter defaults from routes
Signed-off-by: jld3103 <[email protected]>
  • Loading branch information
provokateurin committed Dec 8, 2023
commit 0ed839f7116dee296770ba9dd7510467747e9c3b
6 changes: 6 additions & 0 deletions generate-spec
Original file line number Diff line number Diff line change
Expand Up @@ -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, "/")) {
Expand Down Expand Up @@ -387,6 +388,7 @@ foreach ($parsedRoutes as $key => $value) {
$verb,
$url,
$requirements,
$defaults,
$classMethodInfo,
$isOCS,
$isCORS,
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down