[Schema] Drop SDK-only name pattern on resources and resource templates (#430)

* [Schema] Drop SDK-only name pattern on resources and resource templates

* Update src/Schema/ResourceDefinition.php

* Update src/Schema/ResourceTemplate.php
This commit is contained in:
Christopher Hertel 2026-08-18 02:09:07 +02:00 • committed by GitHub
commit d5351759d7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -116,6 +116,30 @@ class ResourceDefinitionTest extends TestCase
$this->assertArrayNotHasKey('title', $data);
}
/**
* The specification puts no pattern on `name`; its own examples use
* names such as "main.rs" and "Project Files".
*/
#[DataProvider('provideSpecExampleNames')]
public function testConstructorAcceptsAnyName(string $name): void
{
$resource = new ResourceDefinition(
uri: self::VALID_URI,
name: $name,
);
$this->assertSame($name, $resource->name);
}
public static function provideSpecExampleNames(): iterable
{
yield 'file name with dot' => ['main.rs'];
yield 'display name with space' => ['Project Files'];
yield 'uppercase file name' => ['README.md'];
yield 'namespaced' => ['acme/reports:quarterly'];
yield 'unicode' => ['Ünïcödé 名前'];
}
#[DataProvider('provideInvalidResources')]
public function testFromArrayInvalid(array $input, string $expectedExceptionMessage): void
{