From 7b582ad9c492699b8874b2616196ce7845209243 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Wed, 30 Aug 2023 01:01:36 +0200 Subject: [PATCH] fix: path var naming collision --- .../io/appwrite/services/ServiceTemplate.kt.twig | 10 +++++----- templates/cli/lib/commands/command.js.twig | 14 +++++++------- templates/dart/base/requests/api.twig | 2 +- templates/dart/base/requests/file.twig | 2 +- templates/dart/base/requests/location.twig | 2 +- templates/dart/base/requests/oauth.twig | 2 +- templates/dart/lib/services/service.dart.twig | 2 +- templates/deno/src/services/service.ts.twig | 10 +++++----- templates/dotnet/base/requests/api.twig | 2 +- templates/dotnet/base/requests/file.twig | 2 +- templates/dotnet/base/requests/location.twig | 2 +- .../src/Appwrite/Services/ServiceTemplate.cs.twig | 2 +- templates/flutter/base/requests/api.twig | 2 +- templates/flutter/base/requests/file.twig | 2 +- templates/flutter/base/requests/location.twig | 2 +- templates/flutter/base/requests/oauth.twig | 2 +- templates/flutter/lib/services/service.dart.twig | 2 +- templates/go/base/requests/api.twig | 2 +- templates/go/services/service.go.twig | 4 ++-- templates/kotlin/base/requests/api.twig | 2 +- templates/kotlin/base/requests/file.twig | 2 +- templates/kotlin/base/requests/location.twig | 2 +- .../io/appwrite/services/ServiceTemplate.kt.twig | 2 +- templates/node/base/requests/api.twig | 2 +- templates/node/base/requests/file.twig | 4 ++-- templates/node/lib/services/service.js.twig | 2 +- templates/php/base/requests/api.twig | 2 +- templates/php/base/requests/file.twig | 8 ++++---- templates/php/src/Services/Service.php.twig | 2 +- templates/python/base/requests/api.twig | 2 +- templates/python/base/requests/file.twig | 2 +- templates/python/package/services/service.py.twig | 2 +- templates/ruby/base/params.twig | 2 +- templates/ruby/base/requests/api.twig | 2 +- templates/ruby/base/requests/file.twig | 2 +- templates/swift/base/params.twig | 2 +- templates/swift/base/requests/OAuth.twig | 2 +- templates/swift/base/requests/api.twig | 2 +- templates/swift/base/requests/file.twig | 2 +- templates/swift/base/requests/location.twig | 2 +- templates/web/src/services/template.ts.twig | 8 ++++---- 41 files changed, 63 insertions(+), 63 deletions(-) diff --git a/templates/android/library/src/main/java/io/appwrite/services/ServiceTemplate.kt.twig b/templates/android/library/src/main/java/io/appwrite/services/ServiceTemplate.kt.twig index f2a331c4e..e1afc8526 100644 --- a/templates/android/library/src/main/java/io/appwrite/services/ServiceTemplate.kt.twig +++ b/templates/android/library/src/main/java/io/appwrite/services/ServiceTemplate.kt.twig @@ -53,7 +53,7 @@ class {{ service.name | caseUcfirst }} : Service { onProgress: ((UploadProgress) -> Unit)? = null {%~ endif %} ){% if method.type != "webAuth" %}: {{ method | returnType(spec, sdk.namespace | caseDot) | raw }}{% endif %} { - val path = "{{ method.path }}" + val apiPath = "{{ method.path }}" {%~ for parameter in method.parameters.path %} .replace("{{ '{' ~ parameter.name | caseCamel ~ '}' }}", {{ parameter.name | caseCamel }}) {%~ endfor %} @@ -88,7 +88,7 @@ class {{ service.name | caseUcfirst }} : Service { } } - val url = Uri.parse("${client.endPoint}${path}?${query.joinToString("&")}") + val url = Uri.parse("${client.endPoint}${apiPath}?${query.joinToString("&")}") val callbackUrlScheme = "{{ spec.title | caseLower }}-callback-${client.config["project"]}" WebAuthComponent.authenticate(activity, url, callbackUrlScheme) { @@ -118,7 +118,7 @@ class {{ service.name | caseUcfirst }} : Service { {%~ elseif method.type == 'location' %} return client.call( "{{ method.method | caseUpper }}", - path, + apiPath, params = params, responseType = {{ method | returnType(spec, sdk.namespace | caseDot) | raw }}::class.java ) @@ -146,7 +146,7 @@ class {{ service.name | caseUcfirst }} : Service { {%~ endif %} {%~ endfor %} return client.chunkedUpload( - path, + apiPath, headers, params, responseType = {{ method | returnType(spec, sdk.namespace | caseDot) | raw }}::class.java, @@ -160,7 +160,7 @@ class {{ service.name | caseUcfirst }} : Service { {%~ else %} return client.call( "{{ method.method | caseUpper }}", - path, + apiPath, headers, params, {%~ if method.responseModel | hasGenericType(spec) %} diff --git a/templates/cli/lib/commands/command.js.twig b/templates/cli/lib/commands/command.js.twig index 3c9addc23..3a747afde 100644 --- a/templates/cli/lib/commands/command.js.twig +++ b/templates/cli/lib/commands/command.js.twig @@ -21,7 +21,7 @@ const {{ service.name | caseLower }}{{ method.name | caseUcfirst }} = async ({ { {% endfor %} let client = !sdk ? await {% if service.name == "projects" %}sdkForConsole(){% else %}sdkForProject(){% endif %} : sdk; - let path = '{{ method.path }}'{% for parameter in method.parameters.path %}.replace('{{ '{' }}{{ parameter.name | caseCamel }}{{ '}' }}', {{ parameter.name | caseCamel | escapeKeyword }}){% endfor %}; + let apiPath = '{{ method.path }}'{% for parameter in method.parameters.path %}.replace('{{ '{' }}{{ parameter.name | caseCamel }}{{ '}' }}', {{ parameter.name | caseCamel | escapeKeyword }}){% endfor %}; let payload = {}; {% if method.parameters.query|length > 0 %} @@ -95,9 +95,9 @@ const {{ service.name | caseLower }}{{ method.name | caseUcfirst }} = async ({ { payload['project'] = localConfig.getProject().projectId payload['key'] = globalConfig.getKey(); const queryParams = new URLSearchParams(payload); - path = `${globalConfig.getEndpoint()}${path}?${queryParams.toString()}`; + apiPath = `${globalConfig.getEndpoint()}${apiPath}?${queryParams.toString()}`; - const response = await client.call('{{ method.method | caseLower }}', path, { + const response = await client.call('{{ method.method | caseLower }}', apiPath, { {% for parameter in method.parameters.header %} '{{ parameter.name }}': ${{ parameter.name | caseCamel | escapeKeyword }}, {% endfor %} @@ -122,7 +122,7 @@ const {{ service.name | caseLower }}{{ method.name | caseUcfirst }} = async ({ { if (size <= libClient.CHUNK_SIZE) { payload['{{ parameter.name }}'] = fs.createReadStream(payload['{{ parameter.name }}']); - response = await client.call('{{ method.method | caseLower }}', path, { + response = await client.call('{{ method.method | caseLower }}', apiPath, { {% for parameter in method.parameters.header %} '{{ parameter.name }}': ${{ parameter.name | caseCamel | escapeKeyword }}, {% endfor %} @@ -154,7 +154,7 @@ const {{ service.name | caseLower }}{{ method.name | caseUcfirst }} = async ({ { {% if parameter.isUploadID %} if({{ parameter.name | caseCamel | escapeKeyword }} != 'unique()') { try { - response = await client.call('get', path + '/' + {{ parameter.name }}, headers); + response = await client.call('get', apiPath + '/' + {{ parameter.name }}, headers); counter = response.chunksUploaded; } catch(e) { } @@ -178,7 +178,7 @@ const {{ service.name | caseLower }}{{ method.name | caseUcfirst }} = async ({ { }); payload['{{ parameter.name }}'] = stream; - response = await client.call('{{ method.method | caseLower }}', path, headers, payload{% if method.type == 'location' %}, 'arraybuffer'{% endif %}); + response = await client.call('{{ method.method | caseLower }}', apiPath, headers, payload{% if method.type == 'location' %}, 'arraybuffer'{% endif %}); if (!id) { id = response['$id']; @@ -198,7 +198,7 @@ const {{ service.name | caseLower }}{{ method.name | caseUcfirst }} = async ({ { {% endif %} {% endfor %} {% else %} - response = await client.call('{{ method.method | caseLower }}', path, { + response = await client.call('{{ method.method | caseLower }}', apiPath, { {% for parameter in method.parameters.header %} '{{ parameter.name }}': ${{ parameter.name | caseCamel | escapeKeyword }}, {% endfor %} diff --git a/templates/dart/base/requests/api.twig b/templates/dart/base/requests/api.twig index 950658e81..e5fb40c83 100644 --- a/templates/dart/base/requests/api.twig +++ b/templates/dart/base/requests/api.twig @@ -8,6 +8,6 @@ {{ utils.map_headers(method.headers) }} }; - final res = await client.call(HttpMethod.{{ method.method | caseLower }}, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.{{ method.method | caseLower }}, path: apiPath, params: params, headers: headers); return {% if method.responseModel and method.responseModel != 'any' %}models.{{method.responseModel | caseUcfirst | overrideIdentifier}}.fromMap(res.data){% else %} res.data{% endif %}; diff --git a/templates/dart/base/requests/file.twig b/templates/dart/base/requests/file.twig index 97d3bcf1a..e90dd3eb3 100644 --- a/templates/dart/base/requests/file.twig +++ b/templates/dart/base/requests/file.twig @@ -19,7 +19,7 @@ {% endif %} {% endfor %} final res = await client.chunkedUpload( - path: path, + path: apiPath, params: params, paramName: paramName, idParamName: idParamName, diff --git a/templates/dart/base/requests/location.twig b/templates/dart/base/requests/location.twig index ab3e3dc4a..5e947787d 100644 --- a/templates/dart/base/requests/location.twig +++ b/templates/dart/base/requests/location.twig @@ -10,5 +10,5 @@ {% endif %} }; - final res = await client.call(HttpMethod.{{ method.method | caseLower }}, path: path, params: params, responseType: ResponseType.bytes); + final res = await client.call(HttpMethod.{{ method.method | caseLower }}, path: apiPath, params: params, responseType: ResponseType.bytes); return res.data; \ No newline at end of file diff --git a/templates/dart/base/requests/oauth.twig b/templates/dart/base/requests/oauth.twig index 237079f36..fd82d84ac 100644 --- a/templates/dart/base/requests/oauth.twig +++ b/templates/dart/base/requests/oauth.twig @@ -27,7 +27,7 @@ Uri url = Uri(scheme: endpoint.scheme, host: endpoint.host, port: endpoint.port, - path: endpoint.path + path, + path: endpoint.path + apiPath, query: query.join('&') ); diff --git a/templates/dart/lib/services/service.dart.twig b/templates/dart/lib/services/service.dart.twig index 00141e5a3..71cba9ccc 100644 --- a/templates/dart/lib/services/service.dart.twig +++ b/templates/dart/lib/services/service.dart.twig @@ -20,7 +20,7 @@ class {{ service.name | caseUcfirst }} extends Service { {{ method.description | dartComment }} {% endif %} {% if method.type == 'location' %}Future{% else %}{% if method.responseModel and method.responseModel != 'any' %}Future{% else %}Future{% endif %}{% endif %} {{ method.name | caseCamel }}({{ _self.method_parameters(method.parameters.all, method.consumes) }}) async { - final String path = '{{ method.path }}'{% for parameter in method.parameters.path %}.replaceAll('{{ '{' }}{{ parameter.name | caseCamel }}{{ '}' }}', {{ parameter.name | caseCamel | overrideIdentifier }}){% endfor %}; + final String apiPath = '{{ method.path }}'{% for parameter in method.parameters.path %}.replaceAll('{{ '{' }}{{ parameter.name | caseCamel }}{{ '}' }}', {{ parameter.name | caseCamel | overrideIdentifier }}){% endfor %}; {% if 'multipart/form-data' in method.consumes %} {{ include('dart/base/requests/file.twig') }} diff --git a/templates/deno/src/services/service.ts.twig b/templates/deno/src/services/service.ts.twig index 8fdd11841..9723d85ae 100644 --- a/templates/deno/src/services/service.ts.twig +++ b/templates/deno/src/services/service.ts.twig @@ -72,8 +72,8 @@ export class {{ service.name | caseUcfirst }} extends Service { {% endif %} {% endfor %} - let path = '{{ method.path }}'{% for parameter in method.parameters.path %}.replace('{{ '{' }}{{ parameter.name }}{{ '}' }}', {{ parameter.name | caseCamel | escapeKeyword }}){% endfor %}; - let payload: Payload = {}; + const apiPath = '{{ method.path }}'{% for parameter in method.parameters.path %}.replace('{{ '{' }}{{ parameter.name }}{{ '}' }}', {{ parameter.name | caseCamel | escapeKeyword }}){% endfor %}; + const payload: Payload = {}; {% for parameter in method.parameters.query %} if (typeof {{ parameter.name | caseCamel | escapeKeyword }} !== 'undefined') { @@ -110,7 +110,7 @@ export class {{ service.name | caseUcfirst }} extends Service { {% if parameter.isUploadID %} if({{ parameter.name | caseCamel | escapeKeyword }} != 'unique()') { try { - response = await this.client.call('get', path + '/' + {{ parameter.name }}, headers); + response = await this.client.call('get', apiPath + '/' + {{ parameter.name }}, headers); chunksUploaded = response.chunksUploaded; } catch(e) { } @@ -151,7 +151,7 @@ export class {{ service.name | caseUcfirst }} extends Service { payload['{{ parameter.name }}'] = { type: 'file', file: new File([uploadableChunkTrimmed], {{ parameter.name | caseCamel | escapeKeyword }}.filename), filename: {{ parameter.name | caseCamel | escapeKeyword }}.filename }; - response = await this.client.call('{{ method.method | caseLower }}', path, headers, payload{% if method.type == 'location' %}, 'arraybuffer'{% endif %}); + response = await this.client.call('{{ method.method | caseLower }}', apiPath, headers, payload{% if method.type == 'location' %}, 'arraybuffer'{% endif %}); if (!id) { id = response['$id']; @@ -193,7 +193,7 @@ export class {{ service.name | caseUcfirst }} extends Service { {% endif %} {% endfor %} {% else %} - return await this.client.call('{{ method.method | caseLower }}', path, { + return await this.client.call('{{ method.method | caseLower }}', apiPath, { {% for parameter in method.parameters.header %} '{{ parameter.name }}': ${{ parameter.name | caseCamel | escapeKeyword }}, {% endfor %} diff --git a/templates/dotnet/base/requests/api.twig b/templates/dotnet/base/requests/api.twig index bf030e99c..a34694ba8 100644 --- a/templates/dotnet/base/requests/api.twig +++ b/templates/dotnet/base/requests/api.twig @@ -1,7 +1,7 @@ {% import 'dotnet/base/utils.twig' as utils %} return _client.Call{% if method.type != 'webAuth' %}<{{ utils.resultType(spec.title, method) }}>{% endif %}( method: "{{ method.method | caseUpper }}", - path: path, + path: apiPath, headers: headers, {%~ if not method.responseModel %} parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!); diff --git a/templates/dotnet/base/requests/file.twig b/templates/dotnet/base/requests/file.twig index 902b5043d..7a2b6c06b 100644 --- a/templates/dotnet/base/requests/file.twig +++ b/templates/dotnet/base/requests/file.twig @@ -7,7 +7,7 @@ {%~ endfor %} return _client.ChunkedUpload( - path, + apiPath, headers, parameters, {%~ if method.responseModel %} diff --git a/templates/dotnet/base/requests/location.twig b/templates/dotnet/base/requests/location.twig index 6b6b1301e..e56b6c6fe 100644 --- a/templates/dotnet/base/requests/location.twig +++ b/templates/dotnet/base/requests/location.twig @@ -1,5 +1,5 @@ return _client.Call( method: "{{ method.method | caseUpper }}", - path: path, + path: apiPath, headers: headers, parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!); \ No newline at end of file diff --git a/templates/dotnet/src/Appwrite/Services/ServiceTemplate.cs.twig b/templates/dotnet/src/Appwrite/Services/ServiceTemplate.cs.twig index a7711ec93..732d36ac7 100644 --- a/templates/dotnet/src/Appwrite/Services/ServiceTemplate.cs.twig +++ b/templates/dotnet/src/Appwrite/Services/ServiceTemplate.cs.twig @@ -27,7 +27,7 @@ namespace {{ spec.title | caseUcfirst }}.Services /// public Task{% if method.type != "webAuth" %}<{{ utils.resultType(spec.title, method) }}>{% endif %} {{ method.name | caseUcfirst }}({{ utils.method_parameters(method.parameters, method.consumes) }}) { - var path = "{{ method.path }}"{% if method.parameters.path | length == 0 %};{% endif %} + var apiPath = "{{ method.path }}"{% if method.parameters.path | length == 0 %};{% endif %} {{~ include('dotnet/base/params.twig') }} diff --git a/templates/flutter/base/requests/api.twig b/templates/flutter/base/requests/api.twig index 233b53490..1e257042b 100644 --- a/templates/flutter/base/requests/api.twig +++ b/templates/flutter/base/requests/api.twig @@ -8,6 +8,6 @@ {{~ utils.map_headers(method.headers) }} }; - final res = await client.call(HttpMethod.{{ method.method | caseLower }}, path: path, params: params, headers: headers); + final res = await client.call(HttpMethod.{{ method.method | caseLower }}, path: apiPath, params: params, headers: headers); return {% if method.responseModel and method.responseModel != 'any' %}models.{{method.responseModel | caseUcfirst | overrideIdentifier}}.fromMap(res.data){% else %} res.data{% endif %}; diff --git a/templates/flutter/base/requests/file.twig b/templates/flutter/base/requests/file.twig index 7a5777115..41094ba04 100644 --- a/templates/flutter/base/requests/file.twig +++ b/templates/flutter/base/requests/file.twig @@ -19,7 +19,7 @@ {% endif %} {% endfor %} final res = await client.chunkedUpload( - path: path, + path: apiPath, params: params, paramName: paramName, idParamName: idParamName, diff --git a/templates/flutter/base/requests/location.twig b/templates/flutter/base/requests/location.twig index 76be6e723..1135c3cad 100644 --- a/templates/flutter/base/requests/location.twig +++ b/templates/flutter/base/requests/location.twig @@ -10,5 +10,5 @@ {% endif %} }; - final res = await client.call(HttpMethod.{{ method.method | caseLower }}, path: path, params: params, responseType: ResponseType.bytes); + final res = await client.call(HttpMethod.{{ method.method | caseLower }}, path: apiPath, params: params, responseType: ResponseType.bytes); return res.data; \ No newline at end of file diff --git a/templates/flutter/base/requests/oauth.twig b/templates/flutter/base/requests/oauth.twig index 36538cd3d..4c5617bd9 100644 --- a/templates/flutter/base/requests/oauth.twig +++ b/templates/flutter/base/requests/oauth.twig @@ -27,7 +27,7 @@ Uri url = Uri(scheme: endpoint.scheme, host: endpoint.host, port: endpoint.port, - path: endpoint.path + path, + path: endpoint.path + apiPath, query: query.join('&') ); diff --git a/templates/flutter/lib/services/service.dart.twig b/templates/flutter/lib/services/service.dart.twig index 0cc609d03..03be8528e 100644 --- a/templates/flutter/lib/services/service.dart.twig +++ b/templates/flutter/lib/services/service.dart.twig @@ -21,7 +21,7 @@ class {{ service.name | caseUcfirst }} extends Service { {{ method.description|dartComment }} {% endif %} {% if method.type == 'webAuth' %}Future{% elseif method.type == 'location' %}Future{% else %}{% if method.responseModel and method.responseModel != 'any' %}Future{% else %}Future{% endif %}{% endif %} {{ method.name | caseCamel }}({{ _self.method_parameters(method.parameters.all, method.consumes) }}) async { - {% if method.parameters.path | length > 0 %}final{% else %}const{% endif %} String path = '{{ method.path }}'{% for parameter in method.parameters.path %}.replaceAll('{{ '{' }}{{ parameter.name | caseCamel }}{{ '}' }}', {{ parameter.name | caseCamel | overrideIdentifier }}){% endfor %}; + {% if method.parameters.path | length > 0 %}final{% else %}const{% endif %} String apiPath = '{{ method.path }}'{% for parameter in method.parameters.path %}.replaceAll('{{ '{' }}{{ parameter.name | caseCamel }}{{ '}' }}', {{ parameter.name | caseCamel | overrideIdentifier }}){% endfor %}; {% if 'multipart/form-data' in method.consumes %} {{ include('flutter/base/requests/file.twig') }} diff --git a/templates/go/base/requests/api.twig b/templates/go/base/requests/api.twig index 034a83680..33e19d6b7 100644 --- a/templates/go/base/requests/api.twig +++ b/templates/go/base/requests/api.twig @@ -1 +1 @@ - return srv.client.Call("{{ method.method | caseUpper }}", path, headers, params) \ No newline at end of file + return srv.client.Call("{{ method.method | caseUpper }}", apiPath, headers, params) \ No newline at end of file diff --git a/templates/go/services/service.go.twig b/templates/go/services/service.go.twig index 2ee676ef0..33a91dc86 100644 --- a/templates/go/services/service.go.twig +++ b/templates/go/services/service.go.twig @@ -29,10 +29,10 @@ func New{{ service.name | caseUcfirst }}(clt Client) *{{ service.name | caseUcfi func (srv *{{ service.name | caseUcfirst }}) {{ method.name | caseUcfirst }}({% if method.parameters.all|length > 0 %}{% for parameter in method.parameters.all %}{{ parameter.name | caseUcfirst }} {{ parameter | typeName }}{% if not loop.last %}, {% endif %}{% endfor %}{% endif %}) (*ClientResponse, error) { {% if method.parameters.path|length > 0 %} r := strings.NewReplacer({% for parameter in method.parameters.path %}"{{ '{' }}{{ parameter.name | caseCamel }}{{ '}' }}", {{ parameter.name | caseUcfirst }}{% if not loop.last %}, {% endif %}{% endfor %}) - path := r.Replace("{{ method.path }}") + apiPath := r.Replace("{{ method.path }}") {% else %} - path := "{{ method.path }}" + apiPath := "{{ method.path }}" {% endif %} {{include('go/base/params.twig')}} diff --git a/templates/kotlin/base/requests/api.twig b/templates/kotlin/base/requests/api.twig index a823ba506..9d23ffd43 100644 --- a/templates/kotlin/base/requests/api.twig +++ b/templates/kotlin/base/requests/api.twig @@ -1,6 +1,6 @@ return client.call( "{{ method.method | caseUpper }}", - path, + apiPath, headers, params, {%~ if method.responseModel | hasGenericType(spec) %} diff --git a/templates/kotlin/base/requests/file.twig b/templates/kotlin/base/requests/file.twig index 4da9ef84d..49bd80635 100644 --- a/templates/kotlin/base/requests/file.twig +++ b/templates/kotlin/base/requests/file.twig @@ -6,7 +6,7 @@ {%~ endif %} {%~ endfor %} return client.chunkedUpload( - path, + apiPath, headers, params, responseType = {{ method | returnType(spec, sdk.namespace | caseDot) | raw }}::class.java, diff --git a/templates/kotlin/base/requests/location.twig b/templates/kotlin/base/requests/location.twig index df3f67171..73589b764 100644 --- a/templates/kotlin/base/requests/location.twig +++ b/templates/kotlin/base/requests/location.twig @@ -1,6 +1,6 @@ return client.call( "{{ method.method | caseUpper }}", - path, + apiPath, params = params, responseType = {{ method | returnType(spec, sdk.namespace | caseDot) | raw }}::class.java ) \ No newline at end of file diff --git a/templates/kotlin/src/main/kotlin/io/appwrite/services/ServiceTemplate.kt.twig b/templates/kotlin/src/main/kotlin/io/appwrite/services/ServiceTemplate.kt.twig index 682752960..e84ec6f01 100644 --- a/templates/kotlin/src/main/kotlin/io/appwrite/services/ServiceTemplate.kt.twig +++ b/templates/kotlin/src/main/kotlin/io/appwrite/services/ServiceTemplate.kt.twig @@ -49,7 +49,7 @@ class {{ service.name | caseUcfirst }} : Service { onProgress: ((UploadProgress) -> Unit)? = null {%~ endif %} ): {{ method | returnType(spec, sdk.namespace | caseDot) | raw }} { - val path = "{{ method.path }}" + val apiPath = "{{ method.path }}" {%~ for parameter in method.parameters.path %} .replace("{{ '{' ~ parameter.name | caseCamel ~ '}' }}", {{ parameter.name | caseCamel }}) {%~ endfor %} diff --git a/templates/node/base/requests/api.twig b/templates/node/base/requests/api.twig index 37ece0471..4c578a889 100644 --- a/templates/node/base/requests/api.twig +++ b/templates/node/base/requests/api.twig @@ -1,4 +1,4 @@ - return await this.client.call('{{ method.method | caseLower }}', path, { + return await this.client.call('{{ method.method | caseLower }}', apiPath, { {% for parameter in method.parameters.header %} '{{ parameter.name }}': ${{ parameter.name | caseCamel | escapeKeyword }}, {% endfor %} diff --git a/templates/node/base/requests/file.twig b/templates/node/base/requests/file.twig index 533dc5d5b..44b1c2183 100644 --- a/templates/node/base/requests/file.twig +++ b/templates/node/base/requests/file.twig @@ -20,7 +20,7 @@ {% if parameter.isUploadID %} if({{ parameter.name | caseCamel | escapeKeyword }} != 'unique()') { try { - response = await this.client.call('get', path + '/' + {{ parameter.name }}, headers); + response = await this.client.call('get', apiPath + '/' + {{ parameter.name }}, headers); chunksUploaded = response.chunksUploaded; } catch(e) { } @@ -53,7 +53,7 @@ const stream = Stream.Readable.from(currentChunk); payload['{{ parameter.name }}'] = { type: 'file', file: stream, filename: {{ parameter.name }}.filename }; - response = await selfClient.call('{{ method.method | caseLower }}', path, headers, payload{% if method.type == 'location' %}, 'arraybuffer'{% endif %}); + response = await selfClient.call('{{ method.method | caseLower }}', apiPath, headers, payload{% if method.type == 'location' %}, 'arraybuffer'{% endif %}); if (!id) { id = response['$id']; diff --git a/templates/node/lib/services/service.js.twig b/templates/node/lib/services/service.js.twig index 5cc919ab3..acfa340a3 100644 --- a/templates/node/lib/services/service.js.twig +++ b/templates/node/lib/services/service.js.twig @@ -29,7 +29,7 @@ class {{ service.name | caseUcfirst }} extends Service { * @returns {Promise} */ async {{ method.name | caseCamel }}({% for parameter in method.parameters.all %}{{ parameter.name | caseCamel | escapeKeyword }}{% if not loop.last %}, {% endif %}{% endfor %}{% if 'multipart/form-data' in method.consumes %}, onProgress = () => {}{% endif %}) { - let path = '{{ method.path }}'{% for parameter in method.parameters.path %}.replace('{{ '{' }}{{ parameter.name | caseCamel }}{{ '}' }}', {{ parameter.name | caseCamel | escapeKeyword }}){% endfor %}; + const apiPath = '{{ method.path }}'{% for parameter in method.parameters.path %}.replace('{{ '{' }}{{ parameter.name | caseCamel }}{{ '}' }}', {{ parameter.name | caseCamel | escapeKeyword }}){% endfor %}; {{ include ('node/base/params.twig')}} {% if 'multipart/form-data' in method.consumes %} {{ include ('node/base/requests/file.twig')}} diff --git a/templates/php/base/requests/api.twig b/templates/php/base/requests/api.twig index 72aee3648..6ba37e385 100644 --- a/templates/php/base/requests/api.twig +++ b/templates/php/base/requests/api.twig @@ -1,4 +1,4 @@ - return $this->client->call(Client::METHOD_{{ method.method | caseUpper }}, $path, [ + return $this->client->call(Client::METHOD_{{ method.method | caseUpper }}, $apiPath, [ {% for parameter in method.parameters.header %} '{{ parameter.name }}' => ${{ parameter.name | caseCamel | escapeKeyword }}, {% endfor %} diff --git a/templates/php/base/requests/file.twig b/templates/php/base/requests/file.twig index 7f9b2d5dc..f2cb8e77a 100644 --- a/templates/php/base/requests/file.twig +++ b/templates/php/base/requests/file.twig @@ -9,7 +9,7 @@ $postedName = ${{ parameter.name | caseCamel }}->getFilename(); if ($size <= Client::CHUNK_SIZE) { $params['{{ parameter.name | caseCamel }}'] = new \CURLFile('data://' . $mimeType . ';base64,' . base64_encode(${{ parameter.name | caseCamel }}->getData()), $mimeType, $postedName); - return $this->client->call(Client::METHOD_POST, $path, [ + return $this->client->call(Client::METHOD_POST, $apiPath, [ {% for param in method.parameters.header %} '{{ param.name }}' => ${{ param.name | caseCamel }}, {% endfor %} @@ -25,7 +25,7 @@ //send single file if size is less than or equal to 5MB if ($size <= Client::CHUNK_SIZE) { $params['{{ parameter.name }}'] = new \CURLFile(${{ parameter.name | caseCamel }}->getPath(), $mimeType, $postedName); - return $this->client->call(Client::METHOD_{{ method.method | caseUpper }}, $path, [ + return $this->client->call(Client::METHOD_{{ method.method | caseUpper }}, $apiPath, [ {% for param in method.parameters.header %} '{{ param.name }}' => ${{ param.name | caseCamel }}, {% endfor %} @@ -43,7 +43,7 @@ {% if parameter.isUploadID %} if(${{ parameter.name | caseCamel | escapeKeyword }} != 'unique()') { try { - $response = $this->client->call(Client::METHOD_GET, $path . '/' . ${{ parameter.name }}); + $response = $this->client->call(Client::METHOD_GET, $apiPath . '/' . ${{ parameter.name }}); $counter = $response['chunksUploaded'] ?? 0; } catch(\Exception $e) { } @@ -72,7 +72,7 @@ if(!empty($id)) { $headers['x-{{spec.title | caseLower }}-id'] = $id; } - $response = $this->client->call(Client::METHOD_POST, $path, $headers, $params); + $response = $this->client->call(Client::METHOD_POST, $apiPath, $headers, $params); $counter++; $start += Client::CHUNK_SIZE; if(empty($id)) { diff --git a/templates/php/src/Services/Service.php.twig b/templates/php/src/Services/Service.php.twig index 3e110cffe..73b9c42c8 100644 --- a/templates/php/src/Services/Service.php.twig +++ b/templates/php/src/Services/Service.php.twig @@ -31,7 +31,7 @@ class {{ service.name | caseUcfirst }} extends Service */ public function {{ method.name | caseCamel }}({% for parameter in method.parameters.all %}{{ parameter | typeName }}${{ parameter.name | caseCamel | escapeKeyword }}{% if not parameter.required %} = null{% endif %}{% if not loop.last %}, {% endif %}{% endfor %}{% if 'multipart/form-data' in method.consumes %}, callable $onProgress = null{% endif %}): {{ method | getReturn }} { - $path = str_replace([{% for parameter in method.parameters.path %}'{{ '{' }}{{ parameter.name | caseCamel }}{{ '}' }}'{% if not loop.last %}, {% endif %}{% endfor %}], [{% for parameter in method.parameters.path %}${{ parameter.name | caseCamel | escapeKeyword }}{% if not loop.last %}, {% endif %}{% endfor %}], '{{ method.path }}'); + $apiPath = str_replace([{% for parameter in method.parameters.path %}'{{ '{' }}{{ parameter.name | caseCamel }}{{ '}' }}'{% if not loop.last %}, {% endif %}{% endfor %}], [{% for parameter in method.parameters.path %}${{ parameter.name | caseCamel | escapeKeyword }}{% if not loop.last %}, {% endif %}{% endfor %}], '{{ method.path }}'); {{ include('php/base/params.twig') }} {% if 'multipart/form-data' in method.consumes %} diff --git a/templates/python/base/requests/api.twig b/templates/python/base/requests/api.twig index defae2819..674b2bdb5 100644 --- a/templates/python/base/requests/api.twig +++ b/templates/python/base/requests/api.twig @@ -1,4 +1,4 @@ - return self.client.call('{{ method.method | caseLower }}', path, { + return self.client.call('{{ method.method | caseLower }}', api_path, { {% for parameter in method.parameters.header %} '{{ parameter.name }}': {{ parameter.name | escapeKeyword | caseSnake }}, {% endfor %} diff --git a/templates/python/base/requests/file.twig b/templates/python/base/requests/file.twig index 8a8d223ff..69a804c88 100644 --- a/templates/python/base/requests/file.twig +++ b/templates/python/base/requests/file.twig @@ -12,7 +12,7 @@ {% endif %} {% endfor %} - return self.client.chunked_upload(path, { + return self.client.chunked_upload(api_path, { {% for parameter in method.parameters.header %} '{{ parameter.name }}': {{ parameter.name | escapeKeyword | caseSnake }}, {% endfor %} diff --git a/templates/python/package/services/service.py.twig b/templates/python/package/services/service.py.twig index df665f003..4f617e437 100644 --- a/templates/python/package/services/service.py.twig +++ b/templates/python/package/services/service.py.twig @@ -12,7 +12,7 @@ class {{ service.name | caseUcfirst }}(Service): """{{ method.title }}""" {% endif %} - path = '{{ method.path }}' + api_path = '{{ method.path }}' {{ include('python/base/params.twig') }} {% if 'multipart/form-data' in method.consumes %} {{ include('python/base/requests/file.twig') }} diff --git a/templates/ruby/base/params.twig b/templates/ruby/base/params.twig index 8483a2bf4..041c4593a 100644 --- a/templates/ruby/base/params.twig +++ b/templates/ruby/base/params.twig @@ -1,4 +1,4 @@ - path = '{{ method.path }}' + api_path = '{{ method.path }}' {% for parameter in method.parameters.path %} .gsub('{{ '{' }}{{ parameter.name }}{{ '}' }}', {{ parameter.name | caseSnake | escapeKeyword }}) {% endfor %} diff --git a/templates/ruby/base/requests/api.twig b/templates/ruby/base/requests/api.twig index 0ac82da49..fdadb6fc9 100644 --- a/templates/ruby/base/requests/api.twig +++ b/templates/ruby/base/requests/api.twig @@ -1,6 +1,6 @@ @client.call( method: '{{ method.method | caseUpper }}', - path: path, + path: api_path, headers: headers, params: params, {% if method.responseModel and method.responseModel != 'any' %} diff --git a/templates/ruby/base/requests/file.twig b/templates/ruby/base/requests/file.twig index f7dcb443e..3aab37999 100644 --- a/templates/ruby/base/requests/file.twig +++ b/templates/ruby/base/requests/file.twig @@ -7,7 +7,7 @@ {% endif %} {% endfor %} @client.chunked_upload( - path: path, + path: api_path, headers: headers, params: params, param_name: param_name, diff --git a/templates/swift/base/params.twig b/templates/swift/base/params.twig index 4fe11e5aa..463500468 100644 --- a/templates/swift/base/params.twig +++ b/templates/swift/base/params.twig @@ -1,4 +1,4 @@ - let path: String = "{{ method.path }}" + let api_path: String = "{{ method.path }}" {%~ for parameter in method.parameters.path %} .replacingOccurrences(of: "{{ '{' }}{{ parameter.name | caseCamel }}{{ '}' }}", with: {{ parameter.name | caseCamel | escapeKeyword }}) {%~ endfor %} diff --git a/templates/swift/base/requests/OAuth.twig b/templates/swift/base/requests/OAuth.twig index a0d0b5c7a..7bd8f8b50 100644 --- a/templates/swift/base/requests/OAuth.twig +++ b/templates/swift/base/requests/OAuth.twig @@ -1,5 +1,5 @@ let query = "?\(client.parametersToQueryString(params: params))" - let url = URL(string: client.endPoint + path + query)! + let url = URL(string: client.endPoint + api_path + query)! let callbackScheme = "appwrite-callback-\(client.config["project"] ?? "")" let group = DispatchGroup() diff --git a/templates/swift/base/requests/api.twig b/templates/swift/base/requests/api.twig index 1798b60bc..1a85bb28c 100644 --- a/templates/swift/base/requests/api.twig +++ b/templates/swift/base/requests/api.twig @@ -1,6 +1,6 @@ return try await client.call( method: "{{ method.method | caseUpper }}", - path: path, + path: api_path, headers: headers, params: params{% if method.responseModel %}, converter: converter diff --git a/templates/swift/base/requests/file.twig b/templates/swift/base/requests/file.twig index 594bbe38b..e1f7568ee 100644 --- a/templates/swift/base/requests/file.twig +++ b/templates/swift/base/requests/file.twig @@ -6,7 +6,7 @@ {% endif %} {% endfor %} return try await client.chunkedUpload( - path: path, + path: api_path, headers: &headers, params: ¶ms, paramName: paramName, diff --git a/templates/swift/base/requests/location.twig b/templates/swift/base/requests/location.twig index a115d056d..bd0f78b47 100644 --- a/templates/swift/base/requests/location.twig +++ b/templates/swift/base/requests/location.twig @@ -1,5 +1,5 @@ return try await client.call( method: "{{ method.method | caseUpper }}", - path: path, + path: api_path, params: params ) \ No newline at end of file diff --git a/templates/web/src/services/template.ts.twig b/templates/web/src/services/template.ts.twig index cd7ddb88a..f68e1b577 100644 --- a/templates/web/src/services/template.ts.twig +++ b/templates/web/src/services/template.ts.twig @@ -34,8 +34,8 @@ export class {{ service.name | caseUcfirst }} extends Service { {% endif %} {% endfor %} - let path = '{{ method.path }}'{% for parameter in method.parameters.path %}.replace('{{ '{' }}{{ parameter.name | caseCamel | escapeKeyword }}{{ '}' }}', {{ parameter.name | caseCamel | escapeKeyword }}){% endfor %}; - let payload: Payload = {}; + const apiPath = '{{ method.path }}'{% for parameter in method.parameters.path %}.replace('{{ '{' }}{{ parameter.name | caseCamel | escapeKeyword }}{{ '}' }}', {{ parameter.name | caseCamel | escapeKeyword }}){% endfor %}; + const payload: Payload = {}; {% for parameter in method.parameters.query %} if (typeof {{ parameter.name | caseCamel | escapeKeyword }} !== 'undefined') { @@ -49,7 +49,7 @@ export class {{ service.name | caseUcfirst }} extends Service { } {% endfor %} - const uri = new URL(this.client.config.endpoint + path); + const uri = new URL(this.client.config.endpoint + apiPath); {% if method.type == 'location' or method.type == 'webAuth' %} {% if method.auth|length > 0 %} {% for node in method.auth %} @@ -112,7 +112,7 @@ export class {{ service.name | caseUcfirst }} extends Service { {% if parameter.isUploadID %} if({{ parameter.name | caseCamel | escapeKeyword }} != 'unique()') { try { - response = await this.client.call('GET', new URL(this.client.config.endpoint + path + '/' + {{ parameter.name }}), headers); + response = await this.client.call('GET', new URL(this.client.config.endpoint + apiPath + '/' + {{ parameter.name }}), headers); counter = response.chunksUploaded; } catch(e) { }