From 75696a21bf3699c1b7e2ae5336ef7a0a4c37ee26 Mon Sep 17 00:00:00 2001 From: Darshan Date: Thu, 15 Jan 2026 11:56:19 +0530 Subject: [PATCH 1/2] update: remove excluded keys from descriptions. --- src/Appwrite/SDK/Specification/Format.php | 200 ++++-------------- .../SDK/Specification/Format/OpenAPI3.php | 8 + .../SDK/Specification/Format/Swagger2.php | 8 + 3 files changed, 52 insertions(+), 164 deletions(-) diff --git a/src/Appwrite/SDK/Specification/Format.php b/src/Appwrite/SDK/Specification/Format.php index ed77e568f4..7cb03c8e1b 100644 --- a/src/Appwrite/SDK/Specification/Format.php +++ b/src/Appwrite/SDK/Specification/Format.php @@ -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); + } } diff --git a/src/Appwrite/SDK/Specification/Format/OpenAPI3.php b/src/Appwrite/SDK/Specification/Format/OpenAPI3.php index 27dcf92923..8171a45db4 100644 --- a/src/Appwrite/SDK/Specification/Format/OpenAPI3.php +++ b/src/Appwrite/SDK/Specification/Format/OpenAPI3.php @@ -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'; diff --git a/src/Appwrite/SDK/Specification/Format/Swagger2.php b/src/Appwrite/SDK/Specification/Format/Swagger2.php index de25a57ccc..990c456851 100644 --- a/src/Appwrite/SDK/Specification/Format/Swagger2.php +++ b/src/Appwrite/SDK/Specification/Format/Swagger2.php @@ -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'; From 206bd63620685792d2f858354e45595eef8a5e21 Mon Sep 17 00:00:00 2001 From: Darshan Date: Thu, 15 Jan 2026 12:04:46 +0530 Subject: [PATCH 2/2] regen: specs. --- app/config/specs/open-api3-latest-client.json | 18 ++++++++++++++++-- app/config/specs/open-api3-latest-console.json | 18 ++++++++++++++++-- app/config/specs/open-api3-latest-server.json | 18 ++++++++++++++++-- app/config/specs/swagger2-latest-client.json | 18 ++++++++++++++++-- app/config/specs/swagger2-latest-console.json | 18 ++++++++++++++++-- app/config/specs/swagger2-latest-server.json | 18 ++++++++++++++++-- 6 files changed, 96 insertions(+), 12 deletions(-) diff --git a/app/config/specs/open-api3-latest-client.json b/app/config/specs/open-api3-latest-client.json index 942e83c234..6aef25072a 100644 --- a/app/config/specs/open-api3-latest-client.json +++ b/app/config/specs/open-api3-latest-client.json @@ -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": { diff --git a/app/config/specs/open-api3-latest-console.json b/app/config/specs/open-api3-latest-console.json index f7cbca76a5..96c074b8ee 100644 --- a/app/config/specs/open-api3-latest-console.json +++ b/app/config/specs/open-api3-latest-console.json @@ -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": { diff --git a/app/config/specs/open-api3-latest-server.json b/app/config/specs/open-api3-latest-server.json index 76e3a2a45c..d86aa78f99 100644 --- a/app/config/specs/open-api3-latest-server.json +++ b/app/config/specs/open-api3-latest-server.json @@ -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": { diff --git a/app/config/specs/swagger2-latest-client.json b/app/config/specs/swagger2-latest-client.json index 1d02df124a..0df8d6f382 100644 --- a/app/config/specs/swagger2-latest-client.json +++ b/app/config/specs/swagger2-latest-client.json @@ -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": { diff --git a/app/config/specs/swagger2-latest-console.json b/app/config/specs/swagger2-latest-console.json index 17064287be..3f2b3d4447 100644 --- a/app/config/specs/swagger2-latest-console.json +++ b/app/config/specs/swagger2-latest-console.json @@ -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": { diff --git a/app/config/specs/swagger2-latest-server.json b/app/config/specs/swagger2-latest-server.json index 6ad3eb4bce..2a452b8658 100644 --- a/app/config/specs/swagger2-latest-server.json +++ b/app/config/specs/swagger2-latest-server.json @@ -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": {