Skip to content
Open
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
116 changes: 62 additions & 54 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion src/Platform/Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,10 @@ public function getParams(): array
* @param bool $deprecated
* @param string $example
* @param array $aliases
* @param Enum|null $enum
* @return self
*/
public function param(string $key, mixed $default, Validator|callable $validator, string $description = '', bool $optional = false, array $injections = [], bool $skipValidation = false, bool $deprecated = false, string $example = '', array $aliases = []): self
public function param(string $key, mixed $default, Validator|callable $validator, string $description = '', bool $optional = false, array $injections = [], bool $skipValidation = false, bool $deprecated = false, string $example = '', array $aliases = [], ?Enum $enum = null): self
{
$param = [
'default' => $default,
Expand All @@ -184,6 +185,7 @@ public function param(string $key, mixed $default, Validator|callable $validator
'deprecated' => $deprecated, // TODO: @Meldiron implement tests
'example' => $example,
'aliases' => $aliases,
'enum' => $enum,
];
$this->options['param:'.$key] = array_merge($param, ['type' => 'param']);
$this->params[$key] = $param;
Expand Down
21 changes: 21 additions & 0 deletions src/Platform/Enum.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace Utopia\Platform;

/**
* Enum metadata for whitelist-backed parameters.
*/
final readonly class Enum
{
/**
* @param string|null $name Generated enum name.
* @param array<string, string>|null $map Mapping of whitelist values to generated enum case names.
* @param list<string>|null $exclude Whitelist values to omit from generated enums.
*/
public function __construct(
public ?string $name = null,
public ?array $map = null,
public ?array $exclude = null,
) {
}
}
Loading
Loading