mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
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:
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'];
|
||||
|
||||
Reference in new issue
Block a user