Skip to content

Commit 2a046a7

Browse files
committed
update API spec URL and add deprecation handling in templates
1 parent 93ffb24 commit 2a046a7

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed

example.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function getSSLPage($url) {
4242
$platform = 'console';
4343
// $platform = 'server';
4444

45-
$spec = getSSLPage("https://raw.githubusercontent.com/appwrite/appwrite/1.7.x/app/config/specs/swagger2-latest-{$platform}.json");
45+
$spec = getSSLPage("https://raw.githubusercontent.com/appwrite/appwrite/deprecate-old-methods/app/config/specs/swagger2-1.8.x-{$platform}.json");
4646

4747
if(empty($spec)) {
4848
throw new Exception('Failed to fetch spec from Appwrite server');

src/SDK/SDK.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,9 @@ public function __construct(Language $language, Spec $spec)
207207
}
208208
return $value;
209209
}));
210+
$this->twig->addFilter(new TwigFilter('capitalizeFirst', function ($value) {
211+
return ucfirst($value);
212+
}));
210213
}
211214

212215
/**

src/Spec/Swagger2.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ protected function parseMethod(string $methodName, string $pathName, array $meth
176176
'consumes' => $method['consumes'] ?? [],
177177
'cookies' => $method['x-appwrite']['cookies'] ?? false,
178178
'type' => $method['x-appwrite']['type'] ?? false,
179+
'deprecated' => $method['x-appwrite']['deprecated'] ?? false,
180+
'replaceWith' => $method['x-appwrite']['replaceWith'] ?? '',
179181
'headers' => [],
180182
'parameters' => [
181183
'all' => [],

templates/android/library/src/main/java/io/package/services/Service.kt.twig

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,18 @@ class {{ service.name | caseUcfirst }}(client: Client) : Service(client) {
3838
* @return [{{ method | returnType(spec, sdk.namespace | caseDot) | raw }}]
3939
{%~ endif %}
4040
*/
41+
{%~ if method.deprecated %}
42+
{% set deprecated_message = "This API is deprecated and uses outdated terminologies." %}
43+
{% if method.replaceWith %}
44+
{% set deprecated_message = deprecated_message ~ ' Please use ' ~ (method.replaceWith | capitalizeFirst) ~ ' instead.' %}
45+
@Deprecated(
46+
"{{ deprecated_message }}",
47+
ReplaceWith("{{ sdk.namespace | caseDot }}.services.{{ method.replaceWith | capitalizeFirst }}")
48+
)
49+
{% else %}
50+
@Deprecated("{{ deprecated_message }}")
51+
{% endif %}
52+
{%~ endif %}
4153
{%~ if method.parameters.all | reduce((carry, param) => carry or not param.required) %}
4254
@JvmOverloads
4355
{%~ endif %}
@@ -192,6 +204,18 @@ class {{ service.name | caseUcfirst }}(client: Client) : Service(client) {
192204
* @return [{{ method | returnType(spec, sdk.namespace | caseDot) | raw }}]
193205
{%~ endif %}
194206
*/
207+
{%~ if method.deprecated %}
208+
{% set deprecated_message = "This API is deprecated and uses outdated terminologies." %}
209+
{% if method.replaceWith %}
210+
{% set deprecated_message = deprecated_message ~ ' Please use ' ~ (method.replaceWith | capitalizeFirst) ~ ' instead.' %}
211+
@Deprecated(
212+
"{{ deprecated_message }}",
213+
ReplaceWith("{{ sdk.namespace | caseDot }}.services.{{ method.replaceWith | capitalizeFirst }}")
214+
)
215+
{% else %}
216+
@Deprecated("{{ deprecated_message }}")
217+
{% endif %}
218+
{%~ endif %}
195219
{%~ if method.parameters.all | reduce((carry, param) => carry or not param.required) %}
196220
@JvmOverloads
197221
{%~ endif %}

0 commit comments

Comments
 (0)