Merge pull request #11141 from appwrite/fix-specs-descriptions

This commit is contained in:
Darshan 2026-01-15 12:08:35 +05:30 committed by GitHub
commit 325968c52a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 148 additions and 176 deletions

View file

@ -13454,6 +13454,16 @@
"description": "Total number of chunks uploaded",
"x-example": 17890,
"format": "int32"
},
"encryption": {
"type": "boolean",
"description": "Whether file contents are encrypted at rest.",
"x-example": true
},
"compression": {
"type": "string",
"description": "Compression algorithm used for the file. Will be one of none, [gzip](https:\/\/en.wikipedia.org\/wiki\/Gzip), or [zstd](https:\/\/en.wikipedia.org\/wiki\/Zstd).",
"x-example": "gzip"
}
},
"required": [
@ -13467,7 +13477,9 @@
"mimeType",
"sizeOriginal",
"chunksTotal",
"chunksUploaded"
"chunksUploaded",
"encryption",
"compression"
],
"example": {
"$id": "5e5ea5c16897e",
@ -13482,7 +13494,9 @@
"mimeType": "image\/png",
"sizeOriginal": 17890,
"chunksTotal": 17890,
"chunksUploaded": 17890
"chunksUploaded": 17890,
"encryption": true,
"compression": "gzip"
}
},
"team": {

View file

@ -55191,6 +55191,16 @@
"description": "Total number of chunks uploaded",
"x-example": 17890,
"format": "int32"
},
"encryption": {
"type": "boolean",
"description": "Whether file contents are encrypted at rest.",
"x-example": true
},
"compression": {
"type": "string",
"description": "Compression algorithm used for the file. Will be one of none, [gzip](https:\/\/en.wikipedia.org\/wiki\/Gzip), or [zstd](https:\/\/en.wikipedia.org\/wiki\/Zstd).",
"x-example": "gzip"
}
},
"required": [
@ -55204,7 +55214,9 @@
"mimeType",
"sizeOriginal",
"chunksTotal",
"chunksUploaded"
"chunksUploaded",
"encryption",
"compression"
],
"example": {
"$id": "5e5ea5c16897e",
@ -55219,7 +55231,9 @@
"mimeType": "image\/png",
"sizeOriginal": 17890,
"chunksTotal": 17890,
"chunksUploaded": 17890
"chunksUploaded": 17890,
"encryption": true,
"compression": "gzip"
}
},
"bucket": {

View file

@ -43244,6 +43244,16 @@
"description": "Total number of chunks uploaded",
"x-example": 17890,
"format": "int32"
},
"encryption": {
"type": "boolean",
"description": "Whether file contents are encrypted at rest.",
"x-example": true
},
"compression": {
"type": "string",
"description": "Compression algorithm used for the file. Will be one of none, [gzip](https:\/\/en.wikipedia.org\/wiki\/Gzip), or [zstd](https:\/\/en.wikipedia.org\/wiki\/Zstd).",
"x-example": "gzip"
}
},
"required": [
@ -43257,7 +43267,9 @@
"mimeType",
"sizeOriginal",
"chunksTotal",
"chunksUploaded"
"chunksUploaded",
"encryption",
"compression"
],
"example": {
"$id": "5e5ea5c16897e",
@ -43272,7 +43284,9 @@
"mimeType": "image\/png",
"sizeOriginal": 17890,
"chunksTotal": 17890,
"chunksUploaded": 17890
"chunksUploaded": 17890,
"encryption": true,
"compression": "gzip"
}
},
"bucket": {

View file

@ -13393,6 +13393,16 @@
"description": "Total number of chunks uploaded",
"x-example": 17890,
"format": "int32"
},
"encryption": {
"type": "boolean",
"description": "Whether file contents are encrypted at rest.",
"x-example": true
},
"compression": {
"type": "string",
"description": "Compression algorithm used for the file. Will be one of none, [gzip](https:\/\/en.wikipedia.org\/wiki\/Gzip), or [zstd](https:\/\/en.wikipedia.org\/wiki\/Zstd).",
"x-example": "gzip"
}
},
"required": [
@ -13406,7 +13416,9 @@
"mimeType",
"sizeOriginal",
"chunksTotal",
"chunksUploaded"
"chunksUploaded",
"encryption",
"compression"
],
"example": {
"$id": "5e5ea5c16897e",
@ -13421,7 +13433,9 @@
"mimeType": "image\/png",
"sizeOriginal": 17890,
"chunksTotal": 17890,
"chunksUploaded": 17890
"chunksUploaded": 17890,
"encryption": true,
"compression": "gzip"
}
},
"team": {

View file

@ -55019,6 +55019,16 @@
"description": "Total number of chunks uploaded",
"x-example": 17890,
"format": "int32"
},
"encryption": {
"type": "boolean",
"description": "Whether file contents are encrypted at rest.",
"x-example": true
},
"compression": {
"type": "string",
"description": "Compression algorithm used for the file. Will be one of none, [gzip](https:\/\/en.wikipedia.org\/wiki\/Gzip), or [zstd](https:\/\/en.wikipedia.org\/wiki\/Zstd).",
"x-example": "gzip"
}
},
"required": [
@ -55032,7 +55042,9 @@
"mimeType",
"sizeOriginal",
"chunksTotal",
"chunksUploaded"
"chunksUploaded",
"encryption",
"compression"
],
"example": {
"$id": "5e5ea5c16897e",
@ -55047,7 +55059,9 @@
"mimeType": "image\/png",
"sizeOriginal": 17890,
"chunksTotal": 17890,
"chunksUploaded": 17890
"chunksUploaded": 17890,
"encryption": true,
"compression": "gzip"
}
},
"bucket": {

View file

@ -43169,6 +43169,16 @@
"description": "Total number of chunks uploaded",
"x-example": 17890,
"format": "int32"
},
"encryption": {
"type": "boolean",
"description": "Whether file contents are encrypted at rest.",
"x-example": true
},
"compression": {
"type": "string",
"description": "Compression algorithm used for the file. Will be one of none, [gzip](https:\/\/en.wikipedia.org\/wiki\/Gzip), or [zstd](https:\/\/en.wikipedia.org\/wiki\/Zstd).",
"x-example": "gzip"
}
},
"required": [
@ -43182,7 +43192,9 @@
"mimeType",
"sizeOriginal",
"chunksTotal",
"chunksUploaded"
"chunksUploaded",
"encryption",
"compression"
],
"example": {
"$id": "5e5ea5c16897e",
@ -43197,7 +43209,9 @@
"mimeType": "image\/png",
"sizeOriginal": 17890,
"chunksTotal": 17890,
"chunksUploaded": 17890
"chunksUploaded": 17890,
"encryption": true,
"compression": "gzip"
}
},
"bucket": {

View file

@ -666,171 +666,16 @@ abstract class Format
public function getResponseEnumName(string $model, string $param): ?string
{
switch ($model) {
case 'attributeString':
switch ($param) {
case 'status':
return 'AttributeStatus';
}
break;
case 'attributeInteger':
switch ($param) {
case 'status':
return 'AttributeStatus';
}
break;
case 'attributeFloat':
switch ($param) {
case 'status':
return 'AttributeStatus';
}
break;
case 'attributeBoolean':
switch ($param) {
case 'status':
return 'AttributeStatus';
}
break;
case 'attributeEmail':
switch ($param) {
case 'status':
return 'AttributeStatus';
}
break;
case 'attributeEnum':
switch ($param) {
case 'status':
return 'AttributeStatus';
}
break;
case 'attributeIp':
switch ($param) {
case 'status':
return 'AttributeStatus';
}
break;
case 'attributeUrl':
switch ($param) {
case 'status':
return 'AttributeStatus';
}
break;
case 'attributeDatetime':
switch ($param) {
case 'status':
return 'AttributeStatus';
}
break;
case 'attributeRelationship':
switch ($param) {
case 'status':
return 'AttributeStatus';
}
break;
case 'attributePoint':
switch ($param) {
case 'status':
return 'AttributeStatus';
}
break;
case 'attributeLine':
switch ($param) {
case 'status':
return 'AttributeStatus';
}
break;
case 'attributePolygon':
switch ($param) {
case 'status':
return 'AttributeStatus';
}
break;
case 'columnString':
switch ($param) {
case 'status':
return 'ColumnStatus';
}
break;
case 'columnInteger':
switch ($param) {
case 'status':
return 'ColumnStatus';
}
break;
case 'columnFloat':
switch ($param) {
case 'status':
return 'ColumnStatus';
}
break;
case 'columnBoolean':
switch ($param) {
case 'status':
return 'ColumnStatus';
}
break;
case 'columnEmail':
switch ($param) {
case 'status':
return 'ColumnStatus';
}
break;
case 'columnEnum':
switch ($param) {
case 'status':
return 'ColumnStatus';
}
break;
case 'columnIp':
switch ($param) {
case 'status':
return 'ColumnStatus';
}
break;
case 'columnUrl':
switch ($param) {
case 'status':
return 'ColumnStatus';
}
break;
case 'columnDatetime':
switch ($param) {
case 'status':
return 'ColumnStatus';
}
break;
case 'columnRelationship':
switch ($param) {
case 'status':
return 'ColumnStatus';
}
break;
case 'columnPoint':
switch ($param) {
case 'status':
return 'ColumnStatus';
}
break;
case 'columnLine':
switch ($param) {
case 'status':
return 'ColumnStatus';
}
break;
case 'columnPolygon':
switch ($param) {
case 'status':
return 'ColumnStatus';
}
break;
case 'healthStatus':
switch ($param) {
case 'status':
return 'HealthCheckStatus';
}
break;
if ($param !== 'status') {
return null;
}
return null;
return match (true) {
$model === 'healthStatus' => 'HealthCheckStatus',
str_starts_with($model, 'attribute') => 'AttributeStatus',
str_starts_with($model, 'column') => 'ColumnStatus',
default => null,
};
}
protected function getNestedModels(Model $model, array &$usedModels): void
@ -852,4 +697,31 @@ abstract class Format
}
}
}
protected function parseDescription(string $description, array $excludedValues): string
{
if (empty($excludedValues)) {
return $description;
}
foreach ($excludedValues as $excludedValue) {
// remove from comma-separated list
$description = preg_replace(
'/,\s*' . preg_quote($excludedValue, '/') . '(?=\s*[,.]|$)/',
'',
$description
);
$description = preg_replace(
'/(?<=:\s|,\s)' . preg_quote($excludedValue, '/') . '\s*,\s*/',
'',
$description
);
}
// clean up double commas and extra spaces
$description = preg_replace('/,\s*,/', ',', $description);
$description = preg_replace('/\s+/', ' ', $description);
return trim($description);
}
}

View file

@ -623,6 +623,10 @@ class OpenAPI3 extends Format
$node['schema']['items']['enum'] = $enumValues;
$node['schema']['items']['x-enum-name'] = $this->getRequestEnumName($sdk->getNamespace() ?? '', $methodName, $name);
$node['schema']['items']['x-enum-keys'] = $enumKeys;
if (!empty($excludeKeys)) {
$node['description'] = $this->parseDescription($node['description'], $excludeKeys);
}
}
if ($validator->getType() === 'integer') {
$node['schema']['items']['format'] = $validator->getFormat() ?? 'int32';
@ -673,6 +677,10 @@ class OpenAPI3 extends Format
$node['schema']['enum'] = $enumValues;
$node['schema']['x-enum-name'] = $this->getRequestEnumName($sdk->getNamespace() ?? '', $methodName, $name);
$node['schema']['x-enum-keys'] = $enumKeys;
if (!empty($excludeKeys)) {
$node['description'] = $this->parseDescription($node['description'], $excludeKeys);
}
}
if ($validator->getType() === 'integer') {
$node['schema']['format'] = $validator->getFormat() ?? 'int32';

View file

@ -607,6 +607,10 @@ class Swagger2 extends Format
$node['items']['enum'] = $enumValues;
$node['items']['x-enum-name'] = $this->getRequestEnumName($namespace, $methodName, $name);
$node['items']['x-enum-keys'] = $enumKeys;
if (!empty($excludeKeys)) {
$node['description'] = $this->parseDescription($node['description'], $excludeKeys);
}
}
if ($validator->getType() === 'integer') {
$node['items']['format'] = $validator->getFormat() ?? 'int32';
@ -651,6 +655,10 @@ class Swagger2 extends Format
$node['enum'] = $enumValues;
$node['x-enum-name'] = $this->getRequestEnumName($namespace, $methodName, $name);
$node['x-enum-keys'] = $enumKeys;
if (!empty($excludeKeys)) {
$node['description'] = $this->parseDescription($node['description'], $excludeKeys);
}
}
if ($validator->getType() === 'integer') {
$node['format'] = $validator->getFormat() ?? 'int32';