refactor(spec): drop the object cases the parameter default now covers

JSON and JSON\ObjectValidator both report TYPE_OBJECT, so the default emits
exactly what their cases did. Assoc keeps its case because it reports
TYPE_ARRAY and is published as an object on purpose.
This commit is contained in:
Chirag Aggarwal committed 2026-08-31 14:47:21 +01:00
1 parent d68394c166
commit 0891542ae1
1 file changed
+2 -6
@@ -731,9 +731,9 @@ class OpenAPI3 extends Format
$node['schema']['format'] = 'url';
$node['schema']['example'] = ($param['example'] ?? '') !== '' ? $param['example'] : 'https://example.com';
break;
case \Utopia\Validator\JSON::class:
case \Utopia\Validator\JSON\ObjectValidator::class:
case \Utopia\Validator\Assoc::class:
// Assoc reports TYPE_ARRAY, so only an explicit case publishes
// it as an object. TYPE_OBJECT is handled by the default.
$node['schema']['type'] = 'object';
$node['schema']['default'] = (empty($param['default'])) ? new \stdClass() : $param['default'];
$node['schema']['example'] = ($param['example'] ?? '') !== '' ? $param['example'] : '{}';
@@ -943,10 +943,6 @@ class OpenAPI3 extends Format
}
break;
default:
// The cases above match on the concrete validator class, so a
// validator that declares itself an object but is not listed
// reaches here and would be published as a string. That is how
// JSON\FCM narrowed serviceAccountJSON in every generated SDK.
if ($validator->getType() === Validator::TYPE_OBJECT) {
$node['schema']['type'] = 'object';
$node['schema']['default'] = empty($param['default']) ? new \stdClass() : $param['default'];