mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
fix: fail specs when docs are missing
This commit is contained in:
+5
-1
@@ -329,17 +329,20 @@ $setResource('bus', function (Registry $register) use ($cli) {
|
||||
|
||||
$setResource('telemetry', fn () => new NoTelemetry(), []);
|
||||
|
||||
$exitCode = 0;
|
||||
|
||||
$cli
|
||||
->error()
|
||||
->inject('error')
|
||||
->inject('logError')
|
||||
->action(function (Throwable $error, callable $logError) use ($taskName) {
|
||||
->action(function (Throwable $error, callable $logError) use ($taskName, &$exitCode) {
|
||||
call_user_func_array($logError, [
|
||||
$error,
|
||||
'Task',
|
||||
$taskName,
|
||||
]);
|
||||
|
||||
$exitCode = 1;
|
||||
Timer::clearAll();
|
||||
});
|
||||
|
||||
@@ -348,3 +351,4 @@ $cli->shutdown()->action(fn () => Timer::clearAll());
|
||||
Runtime::enableCoroutine(SWOOLE_HOOK_ALL);
|
||||
require_once __DIR__ . '/init/span.php';
|
||||
run($cli->run(...));
|
||||
Console::exit($exitCode);
|
||||
|
||||
@@ -210,6 +210,25 @@ abstract class Format
|
||||
return $this->services;
|
||||
}
|
||||
|
||||
protected function getDescriptionContents(?string $description): string
|
||||
{
|
||||
if ($description === null || $description === '') {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (!\str_ends_with($description, '.md')) {
|
||||
return $description;
|
||||
}
|
||||
|
||||
$contents = @\file_get_contents($description);
|
||||
|
||||
if ($contents === false) {
|
||||
throw new \RuntimeException('Documentation file not found or unreadable: ' . $description);
|
||||
}
|
||||
|
||||
return $contents;
|
||||
}
|
||||
|
||||
protected function getRequestEnumName(string $service, string $method, string $param): ?string
|
||||
{
|
||||
/* `$service` is `$namespace` */
|
||||
|
||||
@@ -128,7 +128,7 @@ class OpenAPI3 extends Format
|
||||
if ($desc === null) {
|
||||
$desc = '';
|
||||
}
|
||||
$descContents = \str_ends_with($desc, '.md') ? \file_get_contents($desc) : $desc;
|
||||
$descContents = $this->getDescriptionContents($desc);
|
||||
|
||||
$temp = [
|
||||
'summary' => $route->getDesc(),
|
||||
@@ -193,7 +193,7 @@ class OpenAPI3 extends Format
|
||||
'parameters' => [],
|
||||
'required' => [],
|
||||
'responses' => [],
|
||||
'description' => ($desc) ? \file_get_contents($desc) : '',
|
||||
'description' => $this->getDescriptionContents($desc),
|
||||
'demo' => \strtolower($namespace) . '/' . Template::fromCamelCaseToDash($methodObj->getMethodName()) . '.md',
|
||||
'public' => $methodObj->isPublic(),
|
||||
];
|
||||
|
||||
@@ -129,7 +129,7 @@ class Swagger2 extends Format
|
||||
if ($desc === null) {
|
||||
$desc = '';
|
||||
}
|
||||
$descContents = \str_ends_with($desc, '.md') ? \file_get_contents($desc) : $desc;
|
||||
$descContents = $this->getDescriptionContents($desc);
|
||||
|
||||
$temp = [
|
||||
'summary' => $route->getDesc(),
|
||||
@@ -201,7 +201,7 @@ class Swagger2 extends Format
|
||||
'parameters' => [],
|
||||
'required' => [],
|
||||
'responses' => [],
|
||||
'description' => ($desc) ? \file_get_contents($desc) : '',
|
||||
'description' => $this->getDescriptionContents($desc),
|
||||
'demo' => \strtolower($namespace) . '/' . Template::fromCamelCaseToDash($methodObj->getMethodName()) . '.md',
|
||||
'public' => $methodObj->isPublic(),
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user