From d68394c166afe781a0e81e3af470ac5fe23fc786 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Mon, 31 Aug 2026 14:45:56 +0100 Subject: [PATCH] test(spec): drop the OpenAPI3 object-type regression test --- tests/unit/SDK/Specification/FormatTest.php | 82 --------------------- 1 file changed, 82 deletions(-) diff --git a/tests/unit/SDK/Specification/FormatTest.php b/tests/unit/SDK/Specification/FormatTest.php index c4424d7c0d..96d05875cf 100644 --- a/tests/unit/SDK/Specification/FormatTest.php +++ b/tests/unit/SDK/Specification/FormatTest.php @@ -54,7 +54,6 @@ use Utopia\Database\Validator\Spatial; use Utopia\DI\Container; use Utopia\Http\Route; use Utopia\Platform\Enum; -use Utopia\Validator; use Utopia\Validator\AnyOf; use Utopia\Validator\ArrayList; use Utopia\Validator\Assoc; @@ -64,62 +63,11 @@ use Utopia\Validator\FloatValidator; use Utopia\Validator\HexColor; use Utopia\Validator\Integer as IntegerValidator; use Utopia\Validator\JSON; -use Utopia\Validator\JSON\FCM; use Utopia\Validator\Nullable; use Utopia\Validator\Range; use Utopia\Validator\Text; use Utopia\Validator\WhiteList; -/** - * Stands in for a validator that reports an object but has no case of its own in - * the OpenAPI3 parameter switch, which is the shape that regressed. - */ -class UnlistedObjectValidator extends Validator -{ - public function getDescription(): string - { - return 'Value must be an object'; - } - - public function isArray(): bool - { - return false; - } - - public function getType(): string - { - return self::TYPE_OBJECT; - } - - public function isValid(mixed $value): bool - { - return \is_array($value) || $value instanceof \stdClass; - } -} - -class UnlistedStringValidator extends Validator -{ - public function getDescription(): string - { - return 'Value must be a string'; - } - - public function isArray(): bool - { - return false; - } - - public function getType(): string - { - return self::TYPE_STRING; - } - - public function isValid(mixed $value): bool - { - return \is_string($value); - } -} - class TestFormat extends Format { public function getName(): string @@ -1092,36 +1040,6 @@ final class FormatTest extends TestCase $this->assertSame('object', $openApiQuery['type']); } - public function testObjectValidatorsWithoutTheirOwnCaseAreNotEmittedAsStrings(): void - { - Method::$processed = []; - Method::$errors = []; - - $route = (new Route('POST', '/v1/tests/fcm')) - ->desc('Create FCM provider') - ->label('sdk', new Method( - namespace: 'test', - group: null, - name: 'createFcmProvider', - description: 'Create FCM provider.', - auth: [], - responses: [], - )) - ->param('serviceAccountJSON', null, new Nullable(new FCM()), 'FCM service account JSON.', true) - ->param('bareServiceAccountJSON', null, new FCM(), 'FCM service account JSON.', true) - ->param('unlistedObject', null, new UnlistedObjectValidator(), 'An object validator with no case of its own.', true) - ->param('unlistedString', null, new UnlistedStringValidator(), 'A string validator with no case of its own.', true); - - $spec = (new OpenAPI3(new Container(), [], [$route], [], [], 0, 'console'))->parse(); - $properties = $spec['paths']['/tests/fcm']['post']['requestBody']['content']['application/json']['schema']['properties']; - - $this->assertSame('object', $properties['serviceAccountJSON']['type']); - $this->assertSame('object', $properties['bareServiceAccountJSON']['type']); - $this->assertSame('object', $properties['unlistedObject']['type']); - $this->assertEquals(new \stdClass(), $properties['unlistedObject']['default']); - $this->assertSame('string', $properties['unlistedString']['type']); - } - public function testJsonAndNullableModelRulesEmitExpectedSchemas(): void { Method::$processed = [];