@autorest/python 6.4.9 → 6.4.11
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.
- package/autorest/codegen/models/__init__.py +1 -1
- package/autorest/codegen/models/code_model.py +4 -1
- package/autorest/codegen/models/model_type.py +1 -0
- package/autorest/codegen/models/paging_operation.py +7 -0
- package/autorest/codegen/models/primitive_types.py +2 -2
- package/autorest/codegen/templates/model_base.py.jinja2 +3 -18
- package/autorest/m4reformatter/__init__.py +1 -1
- package/autorest/preprocess/__init__.py +1 -1
- package/package.json +1 -1
|
@@ -184,7 +184,10 @@ class CodeModel: # pylint: disable=too-many-public-methods
|
|
|
184
184
|
"""All of the model types in this class"""
|
|
185
185
|
if not self._model_types:
|
|
186
186
|
self._model_types = [
|
|
187
|
-
t
|
|
187
|
+
t
|
|
188
|
+
for t in self.types_map.values()
|
|
189
|
+
if isinstance(t, ModelType)
|
|
190
|
+
and not (self.options["models_mode"] == "dpg" and t.page_result_model)
|
|
188
191
|
]
|
|
189
192
|
return self._model_types
|
|
190
193
|
|
|
@@ -74,6 +74,7 @@ class ModelType( # pylint: disable=abstract-method
|
|
|
74
74
|
self._got_polymorphic_subtypes = False
|
|
75
75
|
self.internal: bool = self.yaml_data.get("internal", False)
|
|
76
76
|
self.snake_case_name: str = self.yaml_data["snakeCaseName"]
|
|
77
|
+
self.page_result_model: bool = self.yaml_data.get("pageResultModel", False)
|
|
77
78
|
|
|
78
79
|
@property
|
|
79
80
|
def is_xml(self) -> bool:
|
|
@@ -156,7 +156,14 @@ class PagingOperationBase(OperationBase[PagingResponseType]):
|
|
|
156
156
|
"azure.core.utils", "case_insensitive_dict", ImportType.AZURECORE
|
|
157
157
|
)
|
|
158
158
|
if self.code_model.options["models_mode"] == "dpg":
|
|
159
|
+
relative_path = "..." if async_mode else ".."
|
|
159
160
|
file_import.merge(self.item_type.imports(**kwargs))
|
|
161
|
+
if self.default_error_deserialization or any(
|
|
162
|
+
r.type for r in self.responses
|
|
163
|
+
):
|
|
164
|
+
file_import.add_submodule_import(
|
|
165
|
+
f"{relative_path}_model_base", "_deserialize", ImportType.LOCAL
|
|
166
|
+
)
|
|
160
167
|
return file_import
|
|
161
168
|
|
|
162
169
|
|
|
@@ -356,7 +356,7 @@ class StringType(PrimitiveType):
|
|
|
356
356
|
class DatetimeType(PrimitiveType):
|
|
357
357
|
def __init__(self, yaml_data: Dict[str, Any], code_model: "CodeModel") -> None:
|
|
358
358
|
super().__init__(yaml_data=yaml_data, code_model=code_model)
|
|
359
|
-
self.format = self.Formats(yaml_data
|
|
359
|
+
self.format = self.Formats(yaml_data.get("format", "date-time"))
|
|
360
360
|
|
|
361
361
|
class Formats(str, Enum):
|
|
362
362
|
datetime = "date-time"
|
|
@@ -588,7 +588,7 @@ class DurationType(PrimitiveType):
|
|
|
588
588
|
class ByteArraySchema(PrimitiveType):
|
|
589
589
|
def __init__(self, yaml_data: Dict[str, Any], code_model: "CodeModel") -> None:
|
|
590
590
|
super().__init__(yaml_data=yaml_data, code_model=code_model)
|
|
591
|
-
self.format = yaml_data
|
|
591
|
+
self.format = yaml_data.get("format", "bytes")
|
|
592
592
|
|
|
593
593
|
@property
|
|
594
594
|
def serialization_type(self) -> str:
|
|
@@ -20,7 +20,7 @@ import isodate
|
|
|
20
20
|
from azure.core.exceptions import DeserializationError
|
|
21
21
|
from azure.core import CaseInsensitiveEnumMeta
|
|
22
22
|
from azure.core.pipeline import PipelineResponse
|
|
23
|
-
from azure.core.serialization import
|
|
23
|
+
from azure.core.serialization import _Null # pylint: disable=protected-access
|
|
24
24
|
|
|
25
25
|
if sys.version_info >= (3, 9):
|
|
26
26
|
from collections.abc import MutableMapping
|
|
@@ -29,24 +29,9 @@ else:
|
|
|
29
29
|
|
|
30
30
|
_LOGGER = logging.getLogger(__name__)
|
|
31
31
|
|
|
32
|
-
__all__ = ["
|
|
32
|
+
__all__ = ["AzureJSONEncoder", "Model", "rest_field", "rest_discriminator"]
|
|
33
33
|
|
|
34
34
|
|
|
35
|
-
class _Null(object):
|
|
36
|
-
"""To create a Falsy object"""
|
|
37
|
-
|
|
38
|
-
def __bool__(self):
|
|
39
|
-
return False
|
|
40
|
-
|
|
41
|
-
__nonzero__ = __bool__ # Python2 compatibility
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
NULL = _Null()
|
|
45
|
-
"""
|
|
46
|
-
A falsy sentinel object which is supposed to be used to specify attributes
|
|
47
|
-
with no data. This gets serialized to `null` on the wire.
|
|
48
|
-
"""
|
|
49
|
-
|
|
50
35
|
TZ_UTC = timezone.utc
|
|
51
36
|
|
|
52
37
|
def _timedelta_as_isostr(td: timedelta) -> str:
|
|
@@ -162,7 +147,7 @@ class AzureJSONEncoder(JSONEncoder):
|
|
|
162
147
|
return {k: v for k, v in o.items() if k not in readonly_props}
|
|
163
148
|
if isinstance(o, (bytes, bytearray)):
|
|
164
149
|
return base64.b64encode(o).decode()
|
|
165
|
-
if o
|
|
150
|
+
if isinstance(o, _Null):
|
|
166
151
|
return None
|
|
167
152
|
try:
|
|
168
153
|
return super(AzureJSONEncoder, self).default(o)
|
|
@@ -234,7 +234,7 @@ def update_primitive( # pylint: disable=too-many-return-statements
|
|
|
234
234
|
base["format"] = yaml_data["format"]
|
|
235
235
|
return base
|
|
236
236
|
if type_group == "byte-array":
|
|
237
|
-
base = _update_type_base("
|
|
237
|
+
base = _update_type_base("bytes", yaml_data)
|
|
238
238
|
base["format"] = yaml_data["format"]
|
|
239
239
|
return base
|
|
240
240
|
return _update_type_base(type_group, yaml_data)
|
|
@@ -220,7 +220,7 @@ class PreProcessPlugin(YamlUpdatePlugin): # pylint: disable=abstract-method
|
|
|
220
220
|
if type.get("name"):
|
|
221
221
|
type["name"] = self.pad_reserved_words(type["name"], PadType.MODEL)
|
|
222
222
|
type["description"] = update_description(
|
|
223
|
-
type
|
|
223
|
+
type.get("description", ""), type["name"]
|
|
224
224
|
)
|
|
225
225
|
type["snakeCaseName"] = to_snake_case(type["name"])
|
|
226
226
|
if type.get("values") and not self.version_tolerant:
|