1
0
Fork 0
mirror of synced 2024-06-30 12:10:51 +12:00

Merge branch 'feat-mysql-test' of github.com:appwrite/appwrite into feat-db-pools

This commit is contained in:
Christy Jacob 2022-10-25 19:26:23 +05:30
commit 2d6a00e56f
7 changed files with 325 additions and 301 deletions

View file

@ -2216,69 +2216,69 @@ $collections = [
],
],
'indexes' => [
[
'$id' => ID::custom('_key_search'),
'type' => Database::INDEX_FULLTEXT,
'attributes' => ['search'],
'lengths' => [2048],
'orders' => [Database::ORDER_ASC],
],
[
'$id' => ID::custom('_key_name'),
'type' => Database::INDEX_KEY,
'attributes' => ['name'],
'lengths' => [2048],
'orders' => [Database::ORDER_ASC],
],
[
'$id' => ID::custom('_key_enabled'),
'type' => Database::INDEX_KEY,
'attributes' => ['enabled'],
'lengths' => [],
'orders' => [Database::ORDER_ASC],
],
[
'$id' => ID::custom('_key_runtime'),
'type' => Database::INDEX_KEY,
'attributes' => ['runtime'],
'lengths' => [2048],
'orders' => [Database::ORDER_ASC],
],
[
'$id' => ID::custom('_key_deployment'),
'type' => Database::INDEX_KEY,
'attributes' => ['deployment'],
'lengths' => [Database::LENGTH_KEY],
'orders' => [Database::ORDER_ASC],
],
[
'$id' => ID::custom('_key_schedule'),
'type' => Database::INDEX_KEY,
'attributes' => ['schedule'],
'lengths' => [128],
'orders' => [Database::ORDER_ASC],
],
[
'$id' => ID::custom('_key_scheduleNext'),
'type' => Database::INDEX_KEY,
'attributes' => ['scheduleNext'],
'lengths' => [],
'orders' => [Database::ORDER_ASC],
],
[
'$id' => ID::custom('_key_schedulePrevious'),
'type' => Database::INDEX_KEY,
'attributes' => ['schedulePrevious'],
'lengths' => [],
'orders' => [Database::ORDER_ASC],
],
[
'$id' => ID::custom('_key_timeout'),
'type' => Database::INDEX_KEY,
'attributes' => ['timeout'],
'lengths' => [],
'orders' => [Database::ORDER_ASC],
],
// [
// '$id' => ID::custom('_key_search'),
// 'type' => Database::INDEX_FULLTEXT,
// 'attributes' => ['search'],
// 'lengths' => [],
// 'orders' => [],
// ],
// [
// '$id' => ID::custom('_key_name'),
// 'type' => Database::INDEX_KEY,
// 'attributes' => ['name'],
// 'lengths' => [700],
// 'orders' => [],
// ],
// [
// '$id' => ID::custom('_key_enabled'),
// 'type' => Database::INDEX_KEY,
// 'attributes' => ['enabled'],
// 'lengths' => [],
// 'orders' => [],
// ],
// [
// '$id' => ID::custom('_key_runtime'),
// 'type' => Database::INDEX_KEY,
// 'attributes' => ['runtime'],
// 'lengths' => [700],
// 'orders' => [],
// ],
// [
// '$id' => ID::custom('_key_deployment'),
// 'type' => Database::INDEX_KEY,
// 'attributes' => ['deployment'],
// 'lengths' => [],
// 'orders' => [],
// ],
// [
// '$id' => ID::custom('_key_schedule'),
// 'type' => Database::INDEX_KEY,
// 'attributes' => ['schedule'],
// 'lengths' => [],
// 'orders' => [],
// ],
// [
// '$id' => ID::custom('_key_scheduleNext'),
// 'type' => Database::INDEX_KEY,
// 'attributes' => ['scheduleNext'],
// 'lengths' => [],
// 'orders' => [],
// ],
// [
// '$id' => ID::custom('_key_schedulePrevious'),
// 'type' => Database::INDEX_KEY,
// 'attributes' => ['schedulePrevious'],
// 'lengths' => [],
// 'orders' => [],
// ],
// [
// '$id' => ID::custom('_key_timeout'),
// 'type' => Database::INDEX_KEY,
// 'attributes' => ['timeout'],
// 'lengths' => [],
// 'orders' => [],
// ],
],
],
@ -2325,7 +2325,7 @@ $collections = [
'$id' => ID::custom('entrypoint'),
'type' => Database::VAR_STRING,
'format' => '',
'size' => 2048,
'size' => 16384,
'signed' => true,
'required' => false,
'default' => null,
@ -2335,7 +2335,7 @@ $collections = [
'$id' => ID::custom('path'),
'type' => Database::VAR_STRING,
'format' => '',
'size' => 2048,
'size' => 16384,
'signed' => true,
'required' => false,
'default' => null,
@ -2410,55 +2410,55 @@ $collections = [
]
],
'indexes' => [
[
'$id' => ID::custom('_key_resource'),
'type' => Database::INDEX_KEY,
'attributes' => ['resourceId'],
'lengths' => [Database::LENGTH_KEY],
'orders' => [Database::ORDER_ASC],
],
[
'$id' => ID::custom('_key_resource_type'),
'type' => Database::INDEX_KEY,
'attributes' => ['resourceType'],
'lengths' => [Database::LENGTH_KEY],
'orders' => [Database::ORDER_ASC],
],
[
'$id' => ID::custom('_key_search'),
'type' => Database::INDEX_FULLTEXT,
'attributes' => ['search'],
'lengths' => [],
'orders' => [],
],
[
'$id' => ID::custom('_key_entrypoint'),
'type' => Database::INDEX_KEY,
'attributes' => ['entrypoint'],
'lengths' => [2048],
'orders' => [Database::ORDER_ASC],
],
[
'$id' => ID::custom('_key_size'),
'type' => Database::INDEX_KEY,
'attributes' => ['size'],
'lengths' => [],
'orders' => [Database::ORDER_ASC],
],
[
'$id' => ID::custom('_key_buildId'),
'type' => Database::INDEX_KEY,
'attributes' => ['buildId'],
'lengths' => [Database::LENGTH_KEY],
'orders' => [Database::ORDER_ASC],
],
[
'$id' => ID::custom('_key_activate'),
'type' => Database::INDEX_KEY,
'attributes' => ['activate'],
'lengths' => [],
'orders' => [Database::ORDER_ASC],
],
// [
// '$id' => ID::custom('_key_resource'),
// 'type' => Database::INDEX_KEY,
// 'attributes' => ['resourceId'],
// 'lengths' => [Database::LENGTH_KEY],
// 'orders' => [Database::ORDER_ASC],
// ],
// [
// '$id' => ID::custom('_key_resource_type'),
// 'type' => Database::INDEX_KEY,
// 'attributes' => ['resourceType'],
// 'lengths' => [Database::LENGTH_KEY],
// 'orders' => [Database::ORDER_ASC],
// ],
// [
// '$id' => ID::custom('_key_search'),
// 'type' => Database::INDEX_FULLTEXT,
// 'attributes' => ['search'],
// 'lengths' => [],
// 'orders' => [],
// ],
// [
// '$id' => ID::custom('_key_entrypoint'),
// 'type' => Database::INDEX_KEY,
// 'attributes' => ['entrypoint'],
// 'lengths' => [Database::LENGTH_KEY],
// 'orders' => [Database::ORDER_ASC],
// ],
// [
// '$id' => ID::custom('_key_size'),
// 'type' => Database::INDEX_KEY,
// 'attributes' => ['size'],
// 'lengths' => [],
// 'orders' => [Database::ORDER_ASC],
// ],
// [
// '$id' => ID::custom('_key_buildId'),
// 'type' => Database::INDEX_KEY,
// 'attributes' => ['buildId'],
// 'lengths' => [Database::LENGTH_KEY],
// 'orders' => [Database::ORDER_ASC],
// ],
// [
// '$id' => ID::custom('_key_activate'),
// 'type' => Database::INDEX_KEY,
// 'attributes' => ['activate'],
// 'lengths' => [],
// 'orders' => [Database::ORDER_ASC],
// ],
],
],
@ -2907,7 +2907,7 @@ $collections = [
'$id' => 'compression',
'type' => Database::VAR_STRING,
'signed' => true,
'size' => 10,
'size' => 128,
'format' => '',
'filters' => [],
'required' => true,
@ -2946,62 +2946,62 @@ $collections = [
],
],
'indexes' => [
[
'$id' => ID::custom('_fulltext_name'),
'type' => Database::INDEX_FULLTEXT,
'attributes' => ['name'],
'lengths' => [1024],
'orders' => [Database::ORDER_ASC],
],
[
'$id' => ID::custom('_key_search'),
'type' => Database::INDEX_FULLTEXT,
'attributes' => ['search'],
'lengths' => [2048],
'orders' => [Database::ORDER_ASC],
],
[
'$id' => ID::custom('_key_enabled'),
'type' => Database::INDEX_KEY,
'attributes' => ['enabled'],
'lengths' => [],
'orders' => [Database::ORDER_ASC],
],
[
'$id' => ID::custom('_key_name'),
'type' => Database::INDEX_KEY,
'attributes' => ['name'],
'lengths' => [128],
'orders' => [Database::ORDER_ASC],
],
[
'$id' => ID::custom('_key_fileSecurity'),
'type' => Database::INDEX_KEY,
'attributes' => ['fileSecurity'],
'lengths' => [],
'orders' => [Database::ORDER_ASC],
],
[
'$id' => ID::custom('_key_maximumFileSize'),
'type' => Database::INDEX_KEY,
'attributes' => ['maximumFileSize'],
'lengths' => [],
'orders' => [Database::ORDER_ASC],
],
[
'$id' => ID::custom('_key_encryption'),
'type' => Database::INDEX_KEY,
'attributes' => ['encryption'],
'lengths' => [],
'orders' => [Database::ORDER_ASC],
],
[
'$id' => ID::custom('_key_antivirus'),
'type' => Database::INDEX_KEY,
'attributes' => ['antivirus'],
'lengths' => [],
'orders' => [Database::ORDER_ASC],
],
// [
// '$id' => ID::custom('_fulltext_name'),
// 'type' => Database::INDEX_FULLTEXT,
// 'attributes' => ['name'],
// 'lengths' => [1024],
// 'orders' => [Database::ORDER_ASC],
// ],
// [
// '$id' => ID::custom('_key_search'),
// 'type' => Database::INDEX_FULLTEXT,
// 'attributes' => ['search'],
// 'lengths' => [],
// 'orders' => [Database::ORDER_ASC],
// ],
// [
// '$id' => ID::custom('_key_enabled'),
// 'type' => Database::INDEX_KEY,
// 'attributes' => ['enabled'],
// 'lengths' => [],
// 'orders' => [Database::ORDER_ASC],
// ],
// [
// '$id' => ID::custom('_key_name'),
// 'type' => Database::INDEX_KEY,
// 'attributes' => ['name'],
// 'lengths' => [128],
// 'orders' => [Database::ORDER_ASC],
// ],
// [
// '$id' => ID::custom('_key_fileSecurity'),
// 'type' => Database::INDEX_KEY,
// 'attributes' => ['fileSecurity'],
// 'lengths' => [],
// 'orders' => [Database::ORDER_ASC],
// ],
// [
// '$id' => ID::custom('_key_maximumFileSize'),
// 'type' => Database::INDEX_KEY,
// 'attributes' => ['maximumFileSize'],
// 'lengths' => [],
// 'orders' => [Database::ORDER_ASC],
// ],
// [
// '$id' => ID::custom('_key_encryption'),
// 'type' => Database::INDEX_KEY,
// 'attributes' => ['encryption'],
// 'lengths' => [],
// 'orders' => [Database::ORDER_ASC],
// ],
// [
// '$id' => ID::custom('_key_antivirus'),
// 'type' => Database::INDEX_KEY,
// 'attributes' => ['antivirus'],
// 'lengths' => [],
// 'orders' => [Database::ORDER_ASC],
// ],
]
],
@ -3390,62 +3390,62 @@ $collections = [
],
],
'indexes' => [
[
'$id' => ID::custom('_key_search'),
'type' => Database::INDEX_FULLTEXT,
'attributes' => ['search'],
'lengths' => [2048],
'orders' => [Database::ORDER_ASC],
],
[
'$id' => ID::custom('_key_bucket'),
'type' => Database::INDEX_KEY,
'attributes' => ['bucketId'],
'lengths' => [Database::LENGTH_KEY],
'orders' => [Database::ORDER_ASC],
],
[
'$id' => ID::custom('_key_name'),
'type' => Database::INDEX_KEY,
'attributes' => ['name'],
'lengths' => [2048],
'orders' => [Database::ORDER_ASC],
],
[
'$id' => ID::custom('_key_signature'),
'type' => Database::INDEX_KEY,
'attributes' => ['signature'],
'lengths' => [2048],
'orders' => [Database::ORDER_ASC],
],
[
'$id' => ID::custom('_key_mimeType'),
'type' => Database::INDEX_KEY,
'attributes' => ['mimeType'],
'lengths' => [127],
'orders' => [Database::ORDER_ASC],
],
[
'$id' => ID::custom('_key_sizeOriginal'),
'type' => Database::INDEX_KEY,
'attributes' => ['sizeOriginal'],
'lengths' => [],
'orders' => [Database::ORDER_ASC],
],
[
'$id' => ID::custom('_key_chunksTotal'),
'type' => Database::INDEX_KEY,
'attributes' => ['chunksTotal'],
'lengths' => [],
'orders' => [Database::ORDER_ASC],
],
[
'$id' => ID::custom('_key_chunksUploaded'),
'type' => Database::INDEX_KEY,
'attributes' => ['chunksUploaded'],
'lengths' => [],
'orders' => [Database::ORDER_ASC],
],
// [
// '$id' => ID::custom('_key_search'),
// 'type' => Database::INDEX_FULLTEXT,
// 'attributes' => ['search'],
// 'lengths' => [],
// 'orders' => [Database::ORDER_ASC],
// ],
// [
// '$id' => ID::custom('_key_bucket'),
// 'type' => Database::INDEX_KEY,
// 'attributes' => ['bucketId'],
// 'lengths' => [Database::LENGTH_KEY],
// 'orders' => [Database::ORDER_ASC],
// ],
// [
// '$id' => ID::custom('_key_name'),
// 'type' => Database::INDEX_KEY,
// 'attributes' => ['name'],
// 'lengths' => [],
// 'orders' => [Database::ORDER_ASC],
// ],
// [
// '$id' => ID::custom('_key_signature'),
// 'type' => Database::INDEX_KEY,
// 'attributes' => ['signature'],
// 'lengths' => [],
// 'orders' => [Database::ORDER_ASC],
// ],
// [
// '$id' => ID::custom('_key_mimeType'),
// 'type' => Database::INDEX_KEY,
// 'attributes' => ['mimeType'],
// 'lengths' => [127],
// 'orders' => [Database::ORDER_ASC],
// ],
// [
// '$id' => ID::custom('_key_sizeOriginal'),
// 'type' => Database::INDEX_KEY,
// 'attributes' => ['sizeOriginal'],
// 'lengths' => [],
// 'orders' => [Database::ORDER_ASC],
// ],
// [
// '$id' => ID::custom('_key_chunksTotal'),
// 'type' => Database::INDEX_KEY,
// 'attributes' => ['chunksTotal'],
// 'lengths' => [],
// 'orders' => [Database::ORDER_ASC],
// ],
// [
// '$id' => ID::custom('_key_chunksUploaded'),
// 'type' => Database::INDEX_KEY,
// 'attributes' => ['chunksUploaded'],
// 'lengths' => [],
// 'orders' => [Database::ORDER_ASC],
// ],
]
],

View file

@ -20,7 +20,7 @@ use Utopia\Database\Database;
use Utopia\Database\Document;
use Utopia\Database\DateTime;
use Utopia\Database\Query;
use Utopia\Database\Adapter\MariaDB;
use Utopia\Database\Adapter\MySQL;
use Utopia\Database\Validator\Authorization;
use Utopia\Database\Validator\Key;
use Utopia\Database\Validator\Permissions;

14
composer.lock generated
View file

@ -2050,16 +2050,16 @@
},
{
"name": "utopia-php/database",
"version": "dev-feat-update-cache-lib",
"version": "0.25.5",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/database.git",
"reference": "44ae47dfd49c9c7c0cba29f6867347e25c23b57b"
"reference": "6d1c1d46d66553154975a3e8e72d30b5bd2413d9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/database/zipball/44ae47dfd49c9c7c0cba29f6867347e25c23b57b",
"reference": "44ae47dfd49c9c7c0cba29f6867347e25c23b57b",
"url": "https://api.github.com/repos/utopia-php/database/zipball/6d1c1d46d66553154975a3e8e72d30b5bd2413d9",
"reference": "6d1c1d46d66553154975a3e8e72d30b5bd2413d9",
"shasum": ""
},
"require": {
@ -2098,9 +2098,9 @@
],
"support": {
"issues": "https://github.com/utopia-php/database/issues",
"source": "https://github.com/utopia-php/database/tree/feat-update-cache-lib"
"source": "https://github.com/utopia-php/database/tree/0.25.5"
},
"time": "2022-10-16T17:35:26+00:00"
"time": "2022-09-30T15:01:32+00:00"
},
{
"name": "utopia-php/domains",
@ -5431,5 +5431,5 @@
"platform-overrides": {
"php": "8.0"
},
"plugin-api-version": "2.3.0"
"plugin-api-version": "2.2.0"
}

View file

@ -10,30 +10,6 @@ x-logging: &x-logging
max-file: '5'
max-size: '10m'
x-env-storage: &x-env-storage |-
_APP_STORAGE_DEVICE
_APP_STORAGE_S3_ACCESS_KEY
_APP_STORAGE_S3_SECRET
_APP_STORAGE_S3_REGION
_APP_STORAGE_S3_BUCKET
_APP_STORAGE_DO_SPACES_ACCESS_KEY
_APP_STORAGE_DO_SPACES_SECRET
_APP_STORAGE_DO_SPACES_REGION
_APP_STORAGE_DO_SPACES_BUCKET
_APP_STORAGE_BACKBLAZE_ACCESS_KEY
_APP_STORAGE_BACKBLAZE_SECRET
_APP_STORAGE_BACKBLAZE_REGION
_APP_STORAGE_BACKBLAZE_BUCKET
_APP_STORAGE_DO_SPACES_BUCKET
_APP_STORAGE_LINODE_ACCESS_KEY
_APP_STORAGE_LINODE_SECRET
_APP_STORAGE_LINODE_REGION
_APP_STORAGE_LINODE_BUCKET
_APP_STORAGE_WASABI_ACCESS_KEY
_APP_STORAGE_WASABI_SECRET
_APP_STORAGE_WASABI_REGION
_APP_STORAGE_WASABI_BUCKET
version: '3'
services:
@ -108,6 +84,7 @@ services:
- ./public:/usr/src/code/public
- ./src:/usr/src/code/src
- ./dev:/usr/local/dev
- ./vendor/utopia-php/database:/usr/src/code/vendor/utopia-php/database
depends_on:
- mariadb
- redis
@ -160,7 +137,27 @@ services:
- _APP_STORAGE_ANTIVIRUS
- _APP_STORAGE_ANTIVIRUS_HOST
- _APP_STORAGE_ANTIVIRUS_PORT
- *x-env-storage
- _APP_STORAGE_DEVICE
- _APP_STORAGE_S3_ACCESS_KEY
- _APP_STORAGE_S3_SECRET
- _APP_STORAGE_S3_REGION
- _APP_STORAGE_S3_BUCKET
- _APP_STORAGE_DO_SPACES_ACCESS_KEY
- _APP_STORAGE_DO_SPACES_SECRET
- _APP_STORAGE_DO_SPACES_REGION
- _APP_STORAGE_DO_SPACES_BUCKET
- _APP_STORAGE_BACKBLAZE_ACCESS_KEY
- _APP_STORAGE_BACKBLAZE_SECRET
- _APP_STORAGE_BACKBLAZE_REGION
- _APP_STORAGE_BACKBLAZE_BUCKET
- _APP_STORAGE_LINODE_ACCESS_KEY
- _APP_STORAGE_LINODE_SECRET
- _APP_STORAGE_LINODE_REGION
- _APP_STORAGE_LINODE_BUCKET
- _APP_STORAGE_WASABI_ACCESS_KEY
- _APP_STORAGE_WASABI_SECRET
- _APP_STORAGE_WASABI_REGION
- _APP_STORAGE_WASABI_BUCKET
- _APP_FUNCTIONS_SIZE_LIMIT
- _APP_FUNCTIONS_TIMEOUT
- _APP_FUNCTIONS_BUILD_TIMEOUT
@ -328,7 +325,27 @@ services:
- _APP_CONNECTIONS_DB_PROJECT
- _APP_CONNECTIONS_CACHE
- _APP_CONNECTIONS_QUEUE
- *x-env-storage
- _APP_STORAGE_DEVICE
- _APP_STORAGE_S3_ACCESS_KEY
- _APP_STORAGE_S3_SECRET
- _APP_STORAGE_S3_REGION
- _APP_STORAGE_S3_BUCKET
- _APP_STORAGE_DO_SPACES_ACCESS_KEY
- _APP_STORAGE_DO_SPACES_SECRET
- _APP_STORAGE_DO_SPACES_REGION
- _APP_STORAGE_DO_SPACES_BUCKET
- _APP_STORAGE_BACKBLAZE_ACCESS_KEY
- _APP_STORAGE_BACKBLAZE_SECRET
- _APP_STORAGE_BACKBLAZE_REGION
- _APP_STORAGE_BACKBLAZE_BUCKET
- _APP_STORAGE_LINODE_ACCESS_KEY
- _APP_STORAGE_LINODE_SECRET
- _APP_STORAGE_LINODE_REGION
- _APP_STORAGE_LINODE_BUCKET
- _APP_STORAGE_WASABI_ACCESS_KEY
- _APP_STORAGE_WASABI_SECRET
- _APP_STORAGE_WASABI_REGION
- _APP_STORAGE_WASABI_BUCKET
- _APP_LOGGING_PROVIDER
- _APP_LOGGING_CONFIG
- _APP_EXECUTOR_SECRET
@ -512,7 +529,27 @@ services:
- OPEN_RUNTIMES_NETWORK
- _APP_LOGGING_PROVIDER
- _APP_LOGGING_CONFIG
- *x-env-storage
- _APP_STORAGE_DEVICE
- _APP_STORAGE_S3_ACCESS_KEY
- _APP_STORAGE_S3_SECRET
- _APP_STORAGE_S3_REGION
- _APP_STORAGE_S3_BUCKET
- _APP_STORAGE_DO_SPACES_ACCESS_KEY
- _APP_STORAGE_DO_SPACES_SECRET
- _APP_STORAGE_DO_SPACES_REGION
- _APP_STORAGE_DO_SPACES_BUCKET
- _APP_STORAGE_BACKBLAZE_ACCESS_KEY
- _APP_STORAGE_BACKBLAZE_SECRET
- _APP_STORAGE_BACKBLAZE_REGION
- _APP_STORAGE_BACKBLAZE_BUCKET
- _APP_STORAGE_LINODE_ACCESS_KEY
- _APP_STORAGE_LINODE_SECRET
- _APP_STORAGE_LINODE_REGION
- _APP_STORAGE_LINODE_BUCKET
- _APP_STORAGE_WASABI_ACCESS_KEY
- _APP_STORAGE_WASABI_SECRET
- _APP_STORAGE_WASABI_REGION
- _APP_STORAGE_WASABI_BUCKET
- DOCKERHUB_PULL_USERNAME
- DOCKERHUB_PULL_PASSWORD

View file

@ -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();

View file

@ -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();

View file

@ -124,56 +124,33 @@ class HTTPTest extends Scope
$this->client->setEndpoint($previousEndpoint);
}
// public function testSpecSwagger2()
// {
// $response = $this->client->call(Client::METHOD_GET, '/specs/swagger2?platform=client', [
// 'content-type' => 'application/json',
// ], []);
// if(!file_put_contents(__DIR__ . '/../../resources/swagger2.json', json_encode($response['body']))) {
// throw new Exception('Failed to save spec file');
// }
// $client = new Client();
// $client->setEndpoint('https://validator.swagger.io');
// /**
// * Test for SUCCESS
// */
// $response = $client->call(Client::METHOD_POST, '/validator/debug', [
// 'content-type' => 'application/json',
// ], json_decode(file_get_contents(realpath(__DIR__ . '/../../resources/swagger2.json')), true));
// $response['body'] = json_decode($response['body'], true);
// $this->assertEquals(200, $response['headers']['status-code']);
// $this->assertTrue(empty($response['body']));
// unlink(realpath(__DIR__ . '/../../resources/swagger2.json'));
// }
public function testSpecOpenAPI3()
public function testSpecs()
{
$response = $this->client->call(Client::METHOD_GET, '/specs/open-api3?platform=console', [
'content-type' => 'application/json',
], []);
$directory = __DIR__ . '/../../../app/config/specs/';
$files = scandir($directory);
$client = new Client();
$client->setEndpoint('https://validator.swagger.io');
$versions = [
'latest',
'0.15.x',
'0.14.x',
];
foreach ($files as $file) {
if (in_array($file, ['.', '..'])) {
continue;
}
if (
(strpos($file, 'latest') === false) &&
(strpos($file, '0.12.x') === false) &&
(strpos($file, '0.13.x') === false)
) {
$allowed = false;
foreach ($versions as $version) {
if (\str_contains($file, $version)) {
$allowed = true;
break;
}
}
if (!$allowed) {
continue;
}
@ -186,7 +163,7 @@ class HTTPTest extends Scope
$response['body'] = json_decode($response['body'], true);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertTrue(empty($response['body']));
$this->assertEmpty($response['body']['schemaValidationMessages']);
}
}