@autorest/python 6.2.2 → 6.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -248,10 +248,9 @@ class DpgModelSerializer(_ModelSerializer):
|
|
|
248
248
|
|
|
249
249
|
@staticmethod
|
|
250
250
|
def declare_property(prop: Property) -> List[str]:
|
|
251
|
-
attribute_key = _ModelSerializer.escape_dot(prop.rest_api_name)
|
|
252
251
|
args = []
|
|
253
|
-
if prop.client_name !=
|
|
254
|
-
args.append(f'name="{
|
|
252
|
+
if prop.client_name != prop.rest_api_name or prop.is_discriminator:
|
|
253
|
+
args.append(f'name="{prop.rest_api_name}"')
|
|
255
254
|
if prop.readonly:
|
|
256
255
|
args.append("readonly=True")
|
|
257
256
|
if prop.client_default_value is not None:
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
# license information.
|
|
5
5
|
# --------------------------------------------------------------------------
|
|
6
6
|
from typing import Any, Dict
|
|
7
|
+
import re
|
|
7
8
|
from .python_mappings import PadType, RESERVED_WORDS, REDEFINED_BUILTINS
|
|
8
9
|
|
|
9
10
|
|
|
@@ -12,6 +13,7 @@ def pad_reserved_words(name: str, pad_type: PadType):
|
|
|
12
13
|
if not name:
|
|
13
14
|
# we'll pass in empty operation groups sometime etc.
|
|
14
15
|
return name
|
|
16
|
+
name = pad_special_chars(name)
|
|
15
17
|
name_prefix = "_" if name[0] == "_" else ""
|
|
16
18
|
name = name[1:] if name[0] == "_" else name
|
|
17
19
|
if name.lower() in RESERVED_WORDS[pad_type]:
|
|
@@ -22,3 +24,7 @@ def pad_reserved_words(name: str, pad_type: PadType):
|
|
|
22
24
|
def add_redefined_builtin_info(name: str, yaml_data: Dict[str, Any]) -> None:
|
|
23
25
|
if name in REDEFINED_BUILTINS:
|
|
24
26
|
yaml_data["pylintDisable"] = "redefined-builtin"
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def pad_special_chars(name: str) -> str:
|
|
30
|
+
return re.sub(r"[^A-z0-9_]", "_", name)
|