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
46 changes: 23 additions & 23 deletions src/Capability/Attribute/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
* definition?: array<string, mixed>,
* type?: string,
* description?: string,
* enum?: array<int, float|string|int>,
* gormat?: string,
* enum?: array<int, int|float|string|null>,
* format?: string,
* minLength?: int,
* maxLength?: int,
* pattern?: string,
Expand Down Expand Up @@ -64,7 +64,7 @@ class Schema
public ?string $description = null;
public mixed $default = null;
/**
* @var ?array<int, float|string|int>
* @var ?array<int, int|float|string|null>
*/
public ?array $enum = null; // list of allowed values
public ?string $format = null; // e.g., 'email', 'date-time'
Expand Down Expand Up @@ -105,26 +105,26 @@ class Schema
public bool|array|null $additionalProperties = null; // true, false, or a schema array

/**
* @param ?array<string, mixed> $definition A complete JSON schema array. If provided, other parameters are ignored.
* @param ?string $type the JSON schema type
* @param ?string $description description of the element
* @param ?array<int, float|string|int> $enum allowed enum values
* @param ?string $format String format (e.g., 'date-time', 'email').
* @param ?int $minLength minimum length for strings
* @param ?int $maxLength maximum length for strings
* @param ?string $pattern regex pattern for strings
* @param int|float|null $minimum minimum value for numbers/integers
* @param int|float|null $maximum maximum value for numbers/integers
* @param ?bool $exclusiveMinimum exclusive minimum
* @param ?bool $exclusiveMaximum exclusive maximum
* @param int|float|null $multipleOf must be a multiple of this value
* @param ?array<string, mixed> $items JSON Schema for items if type is 'array'
* @param ?int $minItems minimum items for an array
* @param ?int $maxItems maximum items for an array
* @param ?bool $uniqueItems whether array items must be unique
* @param ?array<string, mixed> $properties Property definitions if type is 'object'. [name => schema_array].
* @param ?array<int, string> $required list of required properties for an object
* @param bool|array<string, mixed>|null $additionalProperties policy for additional properties in an object
* @param ?array<string, mixed> $definition A complete JSON schema array. If provided, other parameters are ignored.
* @param ?string $type the JSON schema type
* @param ?string $description description of the element
* @param ?array<int, int|float|string|null> $enum allowed enum values
* @param ?string $format String format (e.g., 'date-time', 'email').
* @param ?int $minLength minimum length for strings
* @param ?int $maxLength maximum length for strings
* @param ?string $pattern regex pattern for strings
* @param int|float|null $minimum minimum value for numbers/integers
* @param int|float|null $maximum maximum value for numbers/integers
* @param ?bool $exclusiveMinimum exclusive minimum
* @param ?bool $exclusiveMaximum exclusive maximum
* @param int|float|null $multipleOf must be a multiple of this value
* @param ?array<string, mixed> $items JSON Schema for items if type is 'array'
* @param ?int $minItems minimum items for an array
* @param ?int $maxItems maximum items for an array
* @param ?bool $uniqueItems whether array items must be unique
* @param ?array<string, mixed> $properties Property definitions if type is 'object'. [name => schema_array].
* @param ?array<int, string> $required list of required properties for an object
* @param bool|array<string, mixed>|null $additionalProperties policy for additional properties in an object
*/
public function __construct(
?array $definition = null,
Expand Down
2 changes: 1 addition & 1 deletion src/Capability/Discovery/SchemaGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
* type?: string|array,
* description?: string,
* default?: mixed,
* enum?: array<string|int>,
* enum?: array<int, int|float|string|null>,
* items?: array<string, mixed>,
* }
* @phpstan-type VariadicParameterSchema array{
Expand Down
3 changes: 3 additions & 0 deletions tests/Unit/Capability/Discovery/SchemaValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,7 @@ private function getSimpleSchema(): array
'active' => ['type' => 'boolean'],
'score' => ['type' => 'number'],
'items' => ['type' => 'array', 'items' => ['type' => 'string']],
'status' => ['enum' => [null, 'active', 'inactive']],
'nullableValue' => ['type' => ['string', 'null']],
'optionalValue' => ['type' => 'string'],
],
Expand All @@ -486,6 +487,7 @@ private function getSimpleSchema(): array
* active: bool,
* score: float,
* items: string[],
* status: 'active'|'inactive'|null,
* nullableValue: null,
* optionalValue: string
* }
Expand All @@ -498,6 +500,7 @@ private function getValidData(): array
'active' => true,
'score' => 99.5,
'items' => ['a', 'b'],
'status' => null,
'nullableValue' => null,
'optionalValue' => 'present',
];
Expand Down