Add meaningful Phone number examples to specs

This commit is contained in:
Vincent (Wen Yu) Ge
2022-10-03 15:06:44 +00:00
parent 80ce2b2464
commit 3281b8bbd4
2 changed files with 11 additions and 1 deletions
@@ -368,6 +368,11 @@ class OpenAPI3 extends Format
$node['schema']['format'] = 'password';
$node['schema']['x-example'] = 'password';
break;
case 'Appwrite\Auth\Validator\Phone':
$node['schema']['type'] = $validator->getType();
$node['schema']['format'] = 'phone';
$node['schema']['x-example'] = '+12065550100'; // In the US, 555 is reserved like example.com
break;
case 'Utopia\Validator\Range':
/** @var \Utopia\Validator\Range $validator */
$node['schema']['type'] = $validator->getType() === Validator::TYPE_FLOAT ? 'number' : $validator->getType();
@@ -305,7 +305,7 @@ class Swagger2 extends Format
case 'Appwrite\Network\Validator\Email':
$node['type'] = $validator->getType();
$node['format'] = 'email';
$node['x-example'] = 'email@example.com';
$node['x-example'] = 'email@examples.com';
break;
case 'Appwrite\Network\Validator\URL':
$node['type'] = $validator->getType();
@@ -365,6 +365,11 @@ class Swagger2 extends Format
$node['format'] = 'password';
$node['x-example'] = 'password';
break;
case 'Appwrite\Auth\Validator\Phone':
$node['type'] = $validator->getType();
$node['format'] = 'phone';
$node['x-example'] = '+12065550100';
break;
case 'Utopia\Validator\Range':
/** @var \Utopia\Validator\Range $validator */
$node['type'] = $validator->getType() === Validator::TYPE_FLOAT ? 'number' : $validator->getType();