fix: use model instead of type

This commit is contained in:
loks0n
2024-09-26 10:56:21 +01:00
parent 43c06c6b70
commit c4a764d175
7 changed files with 32 additions and 11 deletions
@@ -576,10 +576,6 @@ class OpenAPI3 extends Format
$type = 'boolean';
break;
case 'payload':
$type = 'payload';
break;
default:
$type = 'object';
$rule['type'] = ($rule['type']) ? $rule['type'] : 'none';
@@ -585,10 +585,6 @@ class Swagger2 extends Format
$type = 'boolean';
break;
case 'payload':
$type = 'payload';
break;
default:
$type = 'object';
$rule['type'] = ($rule['type']) ?: 'none';
+1
View File
@@ -251,6 +251,7 @@ class Response extends SwooleResponse
public const MODEL_RUNTIME_LIST = 'runtimeList';
public const MODEL_DEPLOYMENT = 'deployment';
public const MODEL_DEPLOYMENT_LIST = 'deploymentList';
public const MODEL_PAYLOAD = 'payload';
public const MODEL_EXECUTION = 'execution';
public const MODEL_EXECUTION_LIST = 'executionList';
public const MODEL_BUILD = 'build';
-1
View File
@@ -11,7 +11,6 @@ abstract class Model
public const TYPE_FLOAT = 'double';
public const TYPE_BOOLEAN = 'boolean';
public const TYPE_JSON = 'json';
public const TYPE_PAYLOAD = 'payload';
public const TYPE_DATETIME = 'datetime';
public const TYPE_DATETIME_EXAMPLE = '2020-10-15T06:38:00.000+00:00';
public const TYPE_RELATIONSHIP = 'relationship';
@@ -81,7 +81,7 @@ class Execution extends Model
'example' => 200,
])
->addRule('responseBody', [
'type' => self::TYPE_PAYLOAD,
'type' => Response::MODEL_PAYLOAD,
'description' => 'HTTP response body. This will return empty unless execution is created as synchronous.',
'default' => '',
])
@@ -0,0 +1,29 @@
<?php
namespace Appwrite\Utopia\Response\Model;
use Appwrite\Utopia\Response;
use Appwrite\Utopia\Response\Model;
class Payload extends Model
{
/**
* Get Name
*
* @return string
*/
public function getName(): string
{
return 'Payload';
}
/**
* Get Type
*
* @return string
*/
public function getType(): string
{
return Response::MODEL_PAYLOAD;
}
}
+1 -1
View File
@@ -133,7 +133,7 @@ class HTTPTest extends Scope
$this->assertEquals(200, $response['headers']['status-code']);
// looks like recent change in the validator
$this->assertTrue(empty($response['body']['schemaValidationMessages']));
$this->assertEmpty($response['body']['schemaValidationMessages'], 'Schema validation failed for ' . $file . ': ' . json_encode($response['body']['schemaValidationMessages'], JSON_PRETTY_PRINT));
}
}