Skip to content

Commit fe94000

Browse files
committed
chore: add deprecated to python
1 parent f458cca commit fe94000

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/SDK/SDK.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,17 @@ public function __construct(Language $language, Spec $spec)
210210
$this->twig->addFilter(new TwigFilter('capitalizeFirst', function ($value) {
211211
return ucfirst($value);
212212
}));
213+
$this->twig->addFilter(new TwigFilter('caseSnakeExceptFirstDot', function ($value) {
214+
$parts = explode('.', $value, 2);
215+
$toSnake = function ($str) {
216+
preg_match_all('!([A-Za-z][A-Z0-9]*(?=$|[A-Z][a-z0-9])|[A-Za-z][a-z0-9]+)!', $str, $matches);
217+
return implode('_', array_map(function ($m) {
218+
return $m === strtoupper($m) ? strtolower($m) : lcfirst($m);
219+
}, $matches[0]));
220+
};
221+
if (count($parts) < 2) return $toSnake($value);
222+
return $parts[0] . '.' . $toSnake($parts[1]);
223+
}));
213224
}
214225

215226
/**

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ class {{ service.name | caseUcfirst }}(Service):
3434

3535
{% if method.parameters.all|length > 0 or 'multipart/form-data' in method.consumes %}
3636

37+
{% if method.deprecated %}
38+
.. deprecated::
39+
This API is deprecated and uses outdated terminologies.{% if method.replaceWith %} Please use `{{ method.replaceWith | caseSnakeExceptFirstDot }}` instead.{% endif %}
40+
{% endif %}
41+
3742
Parameters
3843
----------
3944
{% for parameter in method.parameters.all %}{{ parameter.name | escapeKeyword | caseSnake }} : {{ parameter | getPropertyType(method) | raw }}

0 commit comments

Comments
 (0)