Address Comments

This commit is contained in:
Bradley Schofield
2025-01-15 12:54:49 +09:00
parent 8d7712a669
commit d6474a85e2
28 changed files with 252 additions and 4658 deletions
@@ -2,7 +2,7 @@
namespace Appwrite\SDK;
enum ResponseType: string
enum ContentType: string
{
case NONE = '';
case JSON = 'application/json';
+11 -11
View File
@@ -20,7 +20,7 @@ class Method
* @param string $description
* @param array<AuthType> $auth
* @param array<SDKResponse> $responses
* @param ResponseType $responseType
* @param ContentType $responseType
* @param MethodType|null $methodType
* @param bool $deprecated
* @param array|bool $hide
@@ -37,8 +37,8 @@ class Method
protected string $description,
protected array $auth,
protected array $responses,
protected ResponseType $responseType = ResponseType::JSON,
protected ?MethodType $methodType = null,
protected ContentType $contentType = ContentType::JSON,
protected ?MethodType $type = null,
protected bool $deprecated = false,
protected array|bool $hide = false,
protected bool $packaging = false,
@@ -157,14 +157,14 @@ class Method
return $this->responses;
}
public function getResponseType(): ResponseType
public function getContentType(): ContentType
{
return $this->responseType;
return $this->contentType;
}
public function getMethodType(): ?MethodType
public function getType(): ?MethodType
{
return $this->methodType;
return $this->type;
}
public function isDeprecated(): bool
@@ -235,15 +235,15 @@ class Method
return $this;
}
public function setResponseType(ResponseType $responseType): self
public function setContentType(ContentType $contentType): self
{
$this->responseType = $responseType;
$this->contentType = $contentType;
return $this;
}
public function setMethodType(?MethodType $methodType): self
public function setType(?MethodType $type): self
{
$this->methodType = $methodType;
$this->type = $type;
return $this;
}
+1 -7
View File
@@ -11,8 +11,7 @@ class Response
*/
public function __construct(
private int $code,
private string|array $model,
private string $description = '',
private string|array $model
) {
}
@@ -25,9 +24,4 @@ class Response
{
return $this->model;
}
public function getDescription(): string
{
return $this->description;
}
}
@@ -149,7 +149,7 @@ class OpenAPI3 extends Format
}
$desc = (!empty($sdk->getDescription())) ? \realpath(__DIR__ . '/../../../../' . $sdk->getDescription()) : null;
$produces = ($sdk->getResponseType())->value;
$produces = ($sdk->getContentType())->value;
$routeSecurity = $sdk->getAuth() ?? [];
$sdkPlatforms = [];
@@ -187,7 +187,7 @@ class OpenAPI3 extends Format
'method' => $method,
'weight' => $route->getOrder(),
'cookies' => $route->getLabel('sdk.cookies', false),
'type' => $sdk->getMethodType()->value ?? '',
'type' => $sdk->getType()->value ?? '',
'deprecated' => $sdk->isDeprecated(),
'demo' => Template::fromCamelCaseToDash($namespace) . '/' . Template::fromCamelCaseToDash($method) . '.md',
'edit' => 'https://github.com/appwrite/appwrite/edit/master' . $sdk->getDescription() ?? '',
@@ -224,7 +224,6 @@ class OpenAPI3 extends Format
/** @var \Appwrite\SDK\Response $response */
$additionalMethod['responses'][] = [
'code' => $response->getCode(),
'description' => $response->getDescription(),
'model' => '#/components/schemas/' . $response->getModel()
];
}
@@ -360,7 +359,7 @@ class OpenAPI3 extends Format
$node['schema']['x-example'] = false;
break;
case 'Appwrite\Utopia\Database\Validator\CustomId':
if ($sdk->getMethodType() === MethodType::UPLOAD) {
if ($sdk->getType() === MethodType::UPLOAD) {
$node['schema']['x-upload-id'] = true;
}
$node['schema']['type'] = $validator->getType();
@@ -145,7 +145,7 @@ class Swagger2 extends Format
}
$desc = (!empty($sdk->getDescription())) ? \realpath(__DIR__ . '/../../../../' . $sdk->getDescription()) : null;
$produces = ($sdk->getResponseType())->value;
$produces = ($sdk->getContentType())->value;
$routeSecurity = $sdk->getAuth() ?? [];
$sdkPlatforms = [];
@@ -185,7 +185,7 @@ class Swagger2 extends Format
'method' => $method,
'weight' => $route->getOrder(),
'cookies' => $route->getLabel('sdk.cookies', false),
'type' => $sdk->getMethodType()->value ?? '',
'type' => $sdk->getType()->value ?? '',
'deprecated' => $sdk->isDeprecated(),
'demo' => Template::fromCamelCaseToDash($namespace) . '/' . Template::fromCamelCaseToDash($method) . '.md',
'edit' => 'https://github.com/appwrite/appwrite/edit/master' . $sdk->getDescription() ?? '',
@@ -210,7 +210,8 @@ class Swagger2 extends Format
'name' => $method->getMethodName(),
'parameters' => [],
'required' => [],
'responses' => []
'responses' => [],
'description' => $method->getDescription(),
];
foreach ($method->getParameters() as $name => $param) {
@@ -225,7 +226,6 @@ class Swagger2 extends Format
/** @var \Appwrite\SDK\Response $response */
$additionalMethod['responses'][] = [
'code' => $response->getCode(),
'description' => $response->getDescription(),
'model' => '#/definitions/' . $response->getModel()
];
}
@@ -377,7 +377,7 @@ class Swagger2 extends Format
$node['x-example'] = false;
break;
case 'Appwrite\Utopia\Database\Validator\CustomId':
if ($sdk->getMethodType() === MethodType::UPLOAD) {
if ($sdk->getType() === MethodType::UPLOAD) {
$node['x-upload-id'] = true;
}
$node['type'] = $validator->getType();