Fix text response schemas in API specs

This commit is contained in:
Chirag Aggarwal
2026-05-14 16:35:08 +05:30
parent 927a5cddc4
commit 6d0a76cf51
2 changed files with 28 additions and 0 deletions
@@ -4,6 +4,7 @@ namespace Appwrite\SDK\Specification\Format;
use Appwrite\Platform\Tasks\Specs;
use Appwrite\SDK\AuthType;
use Appwrite\SDK\ContentType;
use Appwrite\SDK\Method;
use Appwrite\SDK\MethodType;
use Appwrite\SDK\Response;
@@ -291,6 +292,21 @@ class OpenAPI3 extends Format
}
if (!(\is_array($model)) && $model->isNone()) {
if ($produces === ContentType::TEXT->value && $response->getCode() !== 204) {
$temp['responses'][(string)$response->getCode()] = [
'description' => 'Text',
'content' => [
$produces => [
'schema' => [
'type' => 'string',
],
],
],
];
continue;
}
$temp['responses'][(string)$response->getCode()] = [
'description' => in_array($produces, [
'image/*',
@@ -4,6 +4,7 @@ namespace Appwrite\SDK\Specification\Format;
use Appwrite\Platform\Tasks\Specs;
use Appwrite\SDK\AuthType;
use Appwrite\SDK\ContentType;
use Appwrite\SDK\Method;
use Appwrite\SDK\MethodType;
use Appwrite\SDK\Response;
@@ -298,6 +299,17 @@ class Swagger2 extends Format
}
if (!(\is_array($model)) && $model->isNone()) {
if ($produces === ContentType::TEXT->value && !\in_array($response->getCode(), [204, 301, 302, 308], true)) {
$temp['responses'][(string)$response->getCode()] = [
'description' => 'Text',
'schema' => [
'type' => 'string',
],
];
continue;
}
$temp['responses'][(string)$response->getCode()] = [
'description' => in_array($produces, [
'image/*',