Skip to content

Commit 1c859b9

Browse files
authored
Merge pull request #1166 from appwrite/fix-snakes
Fix snake language multi gen with same cased name
2 parents ecdbbf7 + 29bed2f commit 1c859b9

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

templates/deno/mod.ts.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { ID } from "./src/id.ts";
66
import { InputFile } from "./src/inputFile.ts";
77
import { {{spec.title | caseUcfirst}}Exception } from "./src/exception.ts";
88
{% for service in spec.services %}
9-
import { {{service.name | caseUcfirst}} } from "./src/services/{{service.name | caseDash}}.ts";
9+
import { {{service.name | caseUcfirst}} } from "./src/services/{{service.name | caseKebab}}.ts";
1010
{% endfor %}
1111
{% for enum in spec.enums %}
1212
import { {{enum.name | caseUcfirst}} } from "./src/enums/{{enum.name | caseKebab}}.ts";

templates/python/package/services/service.py.twig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,17 @@ class {{ service.name | caseUcfirst }}(Service):
2727
def __init__(self, client) -> None:
2828
super({{ service.name | caseUcfirst }}, self).__init__(client)
2929
{% for method in service.methods %}
30+
{% set methodNameSnake = method.name | caseSnake %}
31+
{# Check if this method should be skipped (is deprecated and has a non-deprecated duplicate) #}
32+
{% set shouldSkip = false %}
33+
{% if method.deprecated %}
34+
{% for otherMethod in service.methods %}
35+
{% if not otherMethod.deprecated and (otherMethod.name | caseSnake) == methodNameSnake %}
36+
{% set shouldSkip = true %}
37+
{% endif %}
38+
{% endfor %}
39+
{% endif %}
40+
{% if not shouldSkip %}
3041

3142
def {{ method.name | caseSnake }}(self{% if method.parameters.all|length > 0 %}, {% endif %}{% for parameter in method.parameters.all %}{{ parameter.name | escapeKeyword | caseSnake }}: {{ parameter | getPropertyType(method) | raw }}{% if not parameter.required %} = None{% endif %}{% if not loop.last %}, {% endif %}{% endfor %}{% if 'multipart/form-data' in method.consumes %}, on_progress = None{% endif %}) -> {% if method.type == 'webAuth' %}str{% elseif method.type == 'location' %}bytes{% else %}Dict[str, Any]{% endif %}:
3243
"""
@@ -76,4 +87,5 @@ class {{ service.name | caseUcfirst }}(Service):
7687
{% else %}
7788
{{ include('python/base/requests/api.twig') }}
7889
{% endif %}
90+
{% endif %}
7991
{% endfor %}

templates/ruby/lib/container/services/service.rb.twig

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,17 @@ module {{spec.title | caseUcfirst}}
88
end
99

1010
{% for method in service.methods %}
11+
{% set methodNameSnake = method.name | caseSnake %}
12+
{# Check if this method should be skipped (is deprecated and has a non-deprecated duplicate) #}
13+
{% set shouldSkip = false %}
14+
{% if method.deprecated %}
15+
{% for otherMethod in service.methods %}
16+
{% if not otherMethod.deprecated and (otherMethod.name | caseSnake) == methodNameSnake %}
17+
{% set shouldSkip = true %}
18+
{% endif %}
19+
{% endfor %}
20+
{% endif %}
21+
{% if not shouldSkip %}
1122
{% if method.deprecated %}
1223
#
1324
{%~ if method.since and method.replaceWith %}
@@ -33,7 +44,7 @@ module {{spec.title | caseUcfirst}}
3344
{% endif %}
3445
end
3546

36-
47+
{% endif %}
3748
{% endfor %}
3849
end
3950
end

0 commit comments

Comments
 (0)