mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Make Method Extendable
This commit is contained in:
@@ -57,12 +57,12 @@ class Method
|
||||
}
|
||||
}
|
||||
|
||||
private function getRouteName(): string
|
||||
protected function getRouteName(): string
|
||||
{
|
||||
return $this->namespace . '.' . $this->name;
|
||||
}
|
||||
|
||||
private function validateMethod(string $name, string $namespace): void
|
||||
protected function validateMethod(string $name, string $namespace): void
|
||||
{
|
||||
if (\in_array($this->getRouteName(), self::$processed)) {
|
||||
self::$errors[] = "Error with {$this->getRouteName()} method: Method already exists in namespace {$namespace}";
|
||||
@@ -71,7 +71,7 @@ class Method
|
||||
self::$processed[] = $this->getRouteName();
|
||||
}
|
||||
|
||||
private function validateAuthTypes(array $authTypes): void
|
||||
protected function validateAuthTypes(array $authTypes): void
|
||||
{
|
||||
foreach ($authTypes as $authType) {
|
||||
if (!($authType instanceof AuthType)) {
|
||||
@@ -80,14 +80,14 @@ class Method
|
||||
}
|
||||
}
|
||||
|
||||
private function validateDesc(string $desc): void
|
||||
protected function validateDesc(string $desc): void
|
||||
{
|
||||
if (empty($desc)) {
|
||||
self::$errors[] = "Error with {$this->getRouteName()} method: Description label is empty";
|
||||
return;
|
||||
}
|
||||
|
||||
$descPath = \realpath(__DIR__ . '/../../../' . $desc);
|
||||
$descPath = $this->getDescriptionFilePath();
|
||||
|
||||
if (!\file_exists($descPath)) {
|
||||
self::$errors[] = "Error with {$this->getRouteName()} method: Description file not found at {$desc}";
|
||||
@@ -95,7 +95,7 @@ class Method
|
||||
}
|
||||
}
|
||||
|
||||
private function validateResponseModel(string|array $responseModel): void
|
||||
protected function validateResponseModel(string|array $responseModel): void
|
||||
{
|
||||
$response = new Response(new HttpResponse());
|
||||
|
||||
@@ -112,7 +112,7 @@ class Method
|
||||
}
|
||||
}
|
||||
|
||||
private function validateNoContent(SDKResponse $response): void
|
||||
protected function validateNoContent(SDKResponse $response): void
|
||||
{
|
||||
if ($response->getCode() === 204) {
|
||||
if ($response->getModel() !== Response::MODEL_NONE) {
|
||||
@@ -136,6 +136,16 @@ class Method
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the absolute path to the description file returning null if the file does not exist.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getDescriptionFilePath(): ?string
|
||||
{
|
||||
return \realpath(__DIR__ . '/../../../' . $this->getDescription()) ?: null;
|
||||
}
|
||||
|
||||
public function getAuth(): array
|
||||
{
|
||||
return $this->auth;
|
||||
|
||||
@@ -148,7 +148,7 @@ class OpenAPI3 extends Format
|
||||
$method = array_keys($method)[0];
|
||||
}
|
||||
|
||||
$desc = (!empty($sdk->getDescription())) ? \realpath(__DIR__ . '/../../../../' . $sdk->getDescription()) : null;
|
||||
$desc = $sdk->getDescriptionFilePath();
|
||||
$produces = ($sdk->getContentType())->value;
|
||||
$routeSecurity = $sdk->getAuth() ?? [];
|
||||
$sdkPlatforms = [];
|
||||
|
||||
@@ -144,7 +144,7 @@ class Swagger2 extends Format
|
||||
$method = array_keys($method)[0];
|
||||
}
|
||||
|
||||
$desc = (!empty($sdk->getDescription())) ? \realpath(__DIR__ . '/../../../../' . $sdk->getDescription()) : null;
|
||||
$desc = $sdk->getDescriptionFilePath();
|
||||
$produces = ($sdk->getContentType())->value;
|
||||
$routeSecurity = $sdk->getAuth() ?? [];
|
||||
$sdkPlatforms = [];
|
||||
|
||||
Reference in New Issue
Block a user