test(spec): drop the OpenAPI3 object-type regression test

This commit is contained in:
Chirag Aggarwal committed 2026-08-31 14:45:56 +01:00
1 parent fc7e0e633d
commit d68394c166
1 file changed
-82
@@ -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 = [];