| 1: | <?php |
| 2: | |
| 3: | declare(strict_types=1); |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | |
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | |
| 14: | namespace Nexus\Mcp\Server\Attribute; |
| 15: | |
| 16: | |
| 17: | |
| 18: | |
| 19: | #[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PARAMETER)] |
| 20: | final readonly class InputSchema |
| 21: | { |
| 22: | |
| 23: | |
| 24: | |
| 25: | |
| 26: | |
| 27: | |
| 28: | |
| 29: | |
| 30: | public function __construct( |
| 31: | public ?array $definition = null, |
| 32: | public ?string $type = null, |
| 33: | public ?string $description = null, |
| 34: | public ?array $enum = null, |
| 35: | public ?string $format = null, |
| 36: | public ?int $minLength = null, |
| 37: | public ?int $maxLength = null, |
| 38: | public ?string $pattern = null, |
| 39: | public null|float|int $minimum = null, |
| 40: | public null|float|int $maximum = null, |
| 41: | public null|float|int $exclusiveMinimum = null, |
| 42: | public null|float|int $exclusiveMaximum = null, |
| 43: | public null|float|int $multipleOf = null, |
| 44: | public ?array $items = null, |
| 45: | public ?int $minItems = null, |
| 46: | public ?int $maxItems = null, |
| 47: | public ?bool $uniqueItems = null, |
| 48: | public ?array $properties = null, |
| 49: | public ?array $required = null, |
| 50: | public null|array|bool $additionalProperties = null, |
| 51: | ) { |
| 52: | } |
| 53: | |
| 54: | |
| 55: | |
| 56: | |
| 57: | public function toArray(): array |
| 58: | { |
| 59: | if (null !== $this->definition) { |
| 60: | return $this->definition; |
| 61: | } |
| 62: | |
| 63: | return array_filter([ |
| 64: | 'type' => $this->type, |
| 65: | 'description' => $this->description, |
| 66: | 'enum' => $this->enum, |
| 67: | 'format' => $this->format, |
| 68: | 'minLength' => $this->minLength, |
| 69: | 'maxLength' => $this->maxLength, |
| 70: | 'pattern' => $this->pattern, |
| 71: | 'minimum' => $this->minimum, |
| 72: | 'maximum' => $this->maximum, |
| 73: | 'exclusiveMinimum' => $this->exclusiveMinimum, |
| 74: | 'exclusiveMaximum' => $this->exclusiveMaximum, |
| 75: | 'multipleOf' => $this->multipleOf, |
| 76: | 'items' => $this->items, |
| 77: | 'minItems' => $this->minItems, |
| 78: | 'maxItems' => $this->maxItems, |
| 79: | 'uniqueItems' => $this->uniqueItems, |
| 80: | 'properties' => $this->properties, |
| 81: | 'required' => $this->required, |
| 82: | 'additionalProperties' => $this->additionalProperties, |
| 83: | ], static fn(mixed $value): bool => null !== $value); |
| 84: | } |
| 85: | } |
| 86: | |