@typespec/http-client-python 0.6.5 → 0.6.7
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/dist/emitter/utils.d.ts.map +1 -1
- package/dist/emitter/utils.js +6 -1
- package/dist/emitter/utils.js.map +1 -1
- package/emitter/src/utils.ts +7 -1
- package/emitter/temp/tsconfig.tsbuildinfo +1 -1
- package/eng/scripts/setup/__pycache__/venvtools.cpython-38.pyc +0 -0
- package/generator/build/lib/pygen/codegen/models/code_model.py +1 -1
- package/generator/build/lib/pygen/codegen/templates/serialization.py.jinja2 +37 -39
- package/generator/build/lib/pygen/preprocess/__init__.py +1 -1
- package/generator/dist/pygen-0.1.0-py3-none-any.whl +0 -0
- package/generator/pygen/codegen/models/code_model.py +1 -1
- package/generator/pygen/codegen/templates/serialization.py.jinja2 +37 -39
- package/generator/pygen/preprocess/__init__.py +1 -1
- package/generator/test/azure/tox.ini +3 -3
- package/generator/test/unbranded/tox.ini +3 -3
- package/package.json +1 -1
|
@@ -313,7 +313,7 @@ class CodeModel: # pylint: disable=too-many-public-methods, disable=too-many-in
|
|
|
313
313
|
:param int schema_id: The yaml id of the schema
|
|
314
314
|
:return: If created, we return the created schema, otherwise, we throw.
|
|
315
315
|
:rtype: ~autorest.models.BaseType
|
|
316
|
-
:raises
|
|
316
|
+
:raises KeyError: if schema is not found
|
|
317
317
|
"""
|
|
318
318
|
try:
|
|
319
319
|
return next(type for id, type in self.types_map.items() if id == schema_id)
|
|
@@ -47,9 +47,7 @@ from typing import (
|
|
|
47
47
|
IO,
|
|
48
48
|
Mapping,
|
|
49
49
|
Callable,
|
|
50
|
-
TypeVar,
|
|
51
50
|
MutableMapping,
|
|
52
|
-
Type,
|
|
53
51
|
List,
|
|
54
52
|
)
|
|
55
53
|
|
|
@@ -60,13 +58,13 @@ except ImportError:
|
|
|
60
58
|
import xml.etree.ElementTree as ET
|
|
61
59
|
|
|
62
60
|
import isodate # type: ignore
|
|
61
|
+
from typing_extensions import Self
|
|
63
62
|
|
|
64
63
|
from {{ code_model.core_library }}.exceptions import DeserializationError, SerializationError
|
|
65
64
|
from {{ code_model.core_library }}.serialization import NULL as CoreNull
|
|
66
65
|
|
|
67
66
|
_BOM = codecs.BOM_UTF8.decode(encoding="utf-8")
|
|
68
67
|
|
|
69
|
-
ModelType = TypeVar("ModelType", bound="Model")
|
|
70
68
|
JSON = MutableMapping[str, Any]
|
|
71
69
|
|
|
72
70
|
|
|
@@ -383,25 +381,25 @@ class Model:
|
|
|
383
381
|
return client_models
|
|
384
382
|
|
|
385
383
|
@classmethod
|
|
386
|
-
def deserialize(cls
|
|
384
|
+
def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self:
|
|
387
385
|
"""Parse a str using the RestAPI syntax and return a model.
|
|
388
386
|
|
|
389
387
|
:param str data: A str using RestAPI structure. JSON by default.
|
|
390
388
|
:param str content_type: JSON by default, set application/xml if XML.
|
|
391
389
|
:returns: An instance of this model
|
|
392
|
-
:raises
|
|
393
|
-
:rtype:
|
|
390
|
+
:raises DeserializationError: if something went wrong
|
|
391
|
+
:rtype: Self
|
|
394
392
|
"""
|
|
395
393
|
deserializer = Deserializer(cls._infer_class_models())
|
|
396
394
|
return deserializer(cls.__name__, data, content_type=content_type) # type: ignore
|
|
397
395
|
|
|
398
396
|
@classmethod
|
|
399
397
|
def from_dict(
|
|
400
|
-
cls
|
|
398
|
+
cls,
|
|
401
399
|
data: Any,
|
|
402
400
|
key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None,
|
|
403
401
|
content_type: Optional[str] = None,
|
|
404
|
-
) ->
|
|
402
|
+
) -> Self:
|
|
405
403
|
"""Parse a dict using given key extractor return a model.
|
|
406
404
|
|
|
407
405
|
By default consider key
|
|
@@ -413,7 +411,7 @@ class Model:
|
|
|
413
411
|
:param str content_type: JSON by default, set application/xml if XML.
|
|
414
412
|
:returns: An instance of this model
|
|
415
413
|
:raises: DeserializationError if something went wrong
|
|
416
|
-
:rtype:
|
|
414
|
+
:rtype: Self
|
|
417
415
|
"""
|
|
418
416
|
deserializer = Deserializer(cls._infer_class_models())
|
|
419
417
|
deserializer.key_extractors = ( # type: ignore
|
|
@@ -559,7 +557,7 @@ class Serializer: # pylint: disable=too-many-public-methods
|
|
|
559
557
|
:param object target_obj: The data to be serialized.
|
|
560
558
|
:param str data_type: The type to be serialized from.
|
|
561
559
|
:rtype: str, dict
|
|
562
|
-
:raises
|
|
560
|
+
:raises SerializationError: if serialization fails.
|
|
563
561
|
:returns: The serialized data.
|
|
564
562
|
"""
|
|
565
563
|
key_transformer = kwargs.get("key_transformer", self.key_transformer)
|
|
@@ -669,8 +667,8 @@ class Serializer: # pylint: disable=too-many-public-methods
|
|
|
669
667
|
:param object data: The data to be serialized.
|
|
670
668
|
:param str data_type: The type to be serialized from.
|
|
671
669
|
:rtype: dict
|
|
672
|
-
:raises
|
|
673
|
-
:raises
|
|
670
|
+
:raises SerializationError: if serialization fails.
|
|
671
|
+
:raises ValueError: if data is None
|
|
674
672
|
:returns: The serialized request body
|
|
675
673
|
"""
|
|
676
674
|
|
|
@@ -714,8 +712,8 @@ class Serializer: # pylint: disable=too-many-public-methods
|
|
|
714
712
|
:param str data_type: The type to be serialized from.
|
|
715
713
|
:rtype: str
|
|
716
714
|
:returns: The serialized URL path
|
|
717
|
-
:raises
|
|
718
|
-
:raises
|
|
715
|
+
:raises TypeError: if serialization fails.
|
|
716
|
+
:raises ValueError: if data is None
|
|
719
717
|
"""
|
|
720
718
|
try:
|
|
721
719
|
output = self.serialize_data(data, data_type, **kwargs)
|
|
@@ -738,8 +736,8 @@ class Serializer: # pylint: disable=too-many-public-methods
|
|
|
738
736
|
:param object data: The data to be serialized.
|
|
739
737
|
:param str data_type: The type to be serialized from.
|
|
740
738
|
:rtype: str, list
|
|
741
|
-
:raises
|
|
742
|
-
:raises
|
|
739
|
+
:raises TypeError: if serialization fails.
|
|
740
|
+
:raises ValueError: if data is None
|
|
743
741
|
:returns: The serialized query parameter
|
|
744
742
|
"""
|
|
745
743
|
try:
|
|
@@ -768,8 +766,8 @@ class Serializer: # pylint: disable=too-many-public-methods
|
|
|
768
766
|
:param object data: The data to be serialized.
|
|
769
767
|
:param str data_type: The type to be serialized from.
|
|
770
768
|
:rtype: str
|
|
771
|
-
:raises
|
|
772
|
-
:raises
|
|
769
|
+
:raises TypeError: if serialization fails.
|
|
770
|
+
:raises ValueError: if data is None
|
|
773
771
|
:returns: The serialized header
|
|
774
772
|
"""
|
|
775
773
|
try:
|
|
@@ -788,9 +786,9 @@ class Serializer: # pylint: disable=too-many-public-methods
|
|
|
788
786
|
|
|
789
787
|
:param object data: The data to be serialized.
|
|
790
788
|
:param str data_type: The type to be serialized from.
|
|
791
|
-
:raises
|
|
792
|
-
:raises
|
|
793
|
-
:raises
|
|
789
|
+
:raises AttributeError: if required data is None.
|
|
790
|
+
:raises ValueError: if data is None
|
|
791
|
+
:raises SerializationError: if serialization fails.
|
|
794
792
|
:returns: The serialized data.
|
|
795
793
|
:rtype: str, int, float, bool, dict, list
|
|
796
794
|
"""
|
|
@@ -1125,7 +1123,7 @@ class Serializer: # pylint: disable=too-many-public-methods
|
|
|
1125
1123
|
|
|
1126
1124
|
:param Datetime attr: Object to be serialized.
|
|
1127
1125
|
:rtype: str
|
|
1128
|
-
:raises
|
|
1126
|
+
:raises TypeError: if format invalid.
|
|
1129
1127
|
:return: serialized rfc
|
|
1130
1128
|
"""
|
|
1131
1129
|
try:
|
|
@@ -1151,7 +1149,7 @@ class Serializer: # pylint: disable=too-many-public-methods
|
|
|
1151
1149
|
|
|
1152
1150
|
:param Datetime attr: Object to be serialized.
|
|
1153
1151
|
:rtype: str
|
|
1154
|
-
:raises
|
|
1152
|
+
:raises SerializationError: if format invalid.
|
|
1155
1153
|
:return: serialized iso
|
|
1156
1154
|
"""
|
|
1157
1155
|
if isinstance(attr, str):
|
|
@@ -1184,7 +1182,7 @@ class Serializer: # pylint: disable=too-many-public-methods
|
|
|
1184
1182
|
|
|
1185
1183
|
:param Datetime attr: Object to be serialized.
|
|
1186
1184
|
:rtype: int
|
|
1187
|
-
:raises
|
|
1185
|
+
:raises SerializationError: if format invalid
|
|
1188
1186
|
:return: serialied unix
|
|
1189
1187
|
"""
|
|
1190
1188
|
if isinstance(attr, int):
|
|
@@ -1421,7 +1419,7 @@ class Deserializer:
|
|
|
1421
1419
|
:param str target_obj: Target data type to deserialize to.
|
|
1422
1420
|
:param requests.Response response_data: REST response object.
|
|
1423
1421
|
:param str content_type: Swagger "produces" if available.
|
|
1424
|
-
:raises
|
|
1422
|
+
:raises DeserializationError: if deserialization fails.
|
|
1425
1423
|
:return: Deserialized object.
|
|
1426
1424
|
:rtype: object
|
|
1427
1425
|
"""
|
|
@@ -1435,7 +1433,7 @@ class Deserializer:
|
|
|
1435
1433
|
|
|
1436
1434
|
:param str target_obj: Target data type to deserialize to.
|
|
1437
1435
|
:param object data: Object to deserialize.
|
|
1438
|
-
:raises
|
|
1436
|
+
:raises DeserializationError: if deserialization fails.
|
|
1439
1437
|
:return: Deserialized object.
|
|
1440
1438
|
:rtype: object
|
|
1441
1439
|
"""
|
|
@@ -1650,7 +1648,7 @@ class Deserializer:
|
|
|
1650
1648
|
|
|
1651
1649
|
:param str data: The response string to be deserialized.
|
|
1652
1650
|
:param str data_type: The type to deserialize to.
|
|
1653
|
-
:raises
|
|
1651
|
+
:raises DeserializationError: if deserialization fails.
|
|
1654
1652
|
:return: Deserialized object.
|
|
1655
1653
|
:rtype: object
|
|
1656
1654
|
"""
|
|
@@ -1732,7 +1730,7 @@ class Deserializer:
|
|
|
1732
1730
|
:param dict attr: Dictionary to be deserialized.
|
|
1733
1731
|
:return: Deserialized object.
|
|
1734
1732
|
:rtype: dict
|
|
1735
|
-
:raises
|
|
1733
|
+
:raises TypeError: if non-builtin datatype encountered.
|
|
1736
1734
|
"""
|
|
1737
1735
|
if attr is None:
|
|
1738
1736
|
return None
|
|
@@ -1778,7 +1776,7 @@ class Deserializer:
|
|
|
1778
1776
|
:param str data_type: deserialization data type.
|
|
1779
1777
|
:return: Deserialized basic type.
|
|
1780
1778
|
:rtype: str, int, float or bool
|
|
1781
|
-
:raises
|
|
1779
|
+
:raises TypeError: if string format is not valid.
|
|
1782
1780
|
"""
|
|
1783
1781
|
# If we're here, data is supposed to be a basic type.
|
|
1784
1782
|
# If it's still an XML node, take the text
|
|
@@ -1869,7 +1867,7 @@ class Deserializer:
|
|
|
1869
1867
|
:param str attr: response string to be deserialized.
|
|
1870
1868
|
:return: Deserialized bytearray
|
|
1871
1869
|
:rtype: bytearray
|
|
1872
|
-
:raises
|
|
1870
|
+
:raises TypeError: if string format invalid.
|
|
1873
1871
|
"""
|
|
1874
1872
|
if isinstance(attr, ET.Element):
|
|
1875
1873
|
attr = attr.text
|
|
@@ -1882,7 +1880,7 @@ class Deserializer:
|
|
|
1882
1880
|
:param str attr: response string to be deserialized.
|
|
1883
1881
|
:return: Deserialized base64 string
|
|
1884
1882
|
:rtype: bytearray
|
|
1885
|
-
:raises
|
|
1883
|
+
:raises TypeError: if string format invalid.
|
|
1886
1884
|
"""
|
|
1887
1885
|
if isinstance(attr, ET.Element):
|
|
1888
1886
|
attr = attr.text
|
|
@@ -1897,7 +1895,7 @@ class Deserializer:
|
|
|
1897
1895
|
|
|
1898
1896
|
:param str attr: response string to be deserialized.
|
|
1899
1897
|
:return: Deserialized decimal
|
|
1900
|
-
:raises
|
|
1898
|
+
:raises DeserializationError: if string format invalid.
|
|
1901
1899
|
:rtype: decimal
|
|
1902
1900
|
"""
|
|
1903
1901
|
if isinstance(attr, ET.Element):
|
|
@@ -1915,7 +1913,7 @@ class Deserializer:
|
|
|
1915
1913
|
:param str attr: response string to be deserialized.
|
|
1916
1914
|
:return: Deserialized int
|
|
1917
1915
|
:rtype: long or int
|
|
1918
|
-
:raises
|
|
1916
|
+
:raises ValueError: if string format invalid.
|
|
1919
1917
|
"""
|
|
1920
1918
|
if isinstance(attr, ET.Element):
|
|
1921
1919
|
attr = attr.text
|
|
@@ -1928,7 +1926,7 @@ class Deserializer:
|
|
|
1928
1926
|
:param str attr: response string to be deserialized.
|
|
1929
1927
|
:return: Deserialized duration
|
|
1930
1928
|
:rtype: TimeDelta
|
|
1931
|
-
:raises
|
|
1929
|
+
:raises DeserializationError: if string format invalid.
|
|
1932
1930
|
"""
|
|
1933
1931
|
if isinstance(attr, ET.Element):
|
|
1934
1932
|
attr = attr.text
|
|
@@ -1946,7 +1944,7 @@ class Deserializer:
|
|
|
1946
1944
|
:param str attr: response string to be deserialized.
|
|
1947
1945
|
:return: Deserialized date
|
|
1948
1946
|
:rtype: Date
|
|
1949
|
-
:raises
|
|
1947
|
+
:raises DeserializationError: if string format invalid.
|
|
1950
1948
|
"""
|
|
1951
1949
|
if isinstance(attr, ET.Element):
|
|
1952
1950
|
attr = attr.text
|
|
@@ -1962,7 +1960,7 @@ class Deserializer:
|
|
|
1962
1960
|
:param str attr: response string to be deserialized.
|
|
1963
1961
|
:return: Deserialized time
|
|
1964
1962
|
:rtype: datetime.time
|
|
1965
|
-
:raises
|
|
1963
|
+
:raises DeserializationError: if string format invalid.
|
|
1966
1964
|
"""
|
|
1967
1965
|
if isinstance(attr, ET.Element):
|
|
1968
1966
|
attr = attr.text
|
|
@@ -1977,7 +1975,7 @@ class Deserializer:
|
|
|
1977
1975
|
:param str attr: response string to be deserialized.
|
|
1978
1976
|
:return: Deserialized RFC datetime
|
|
1979
1977
|
:rtype: Datetime
|
|
1980
|
-
:raises
|
|
1978
|
+
:raises DeserializationError: if string format invalid.
|
|
1981
1979
|
"""
|
|
1982
1980
|
if isinstance(attr, ET.Element):
|
|
1983
1981
|
attr = attr.text
|
|
@@ -2000,7 +1998,7 @@ class Deserializer:
|
|
|
2000
1998
|
:param str attr: response string to be deserialized.
|
|
2001
1999
|
:return: Deserialized ISO datetime
|
|
2002
2000
|
:rtype: Datetime
|
|
2003
|
-
:raises
|
|
2001
|
+
:raises DeserializationError: if string format invalid.
|
|
2004
2002
|
"""
|
|
2005
2003
|
if isinstance(attr, ET.Element):
|
|
2006
2004
|
attr = attr.text
|
|
@@ -2038,7 +2036,7 @@ class Deserializer:
|
|
|
2038
2036
|
:param int attr: Object to be serialized.
|
|
2039
2037
|
:return: Deserialized datetime
|
|
2040
2038
|
:rtype: Datetime
|
|
2041
|
-
:raises
|
|
2039
|
+
:raises DeserializationError: if format invalid
|
|
2042
2040
|
"""
|
|
2043
2041
|
if isinstance(attr, ET.Element):
|
|
2044
2042
|
attr = int(attr.text) # type: ignore
|
|
@@ -92,9 +92,9 @@ def add_overloads_for_body_param(yaml_data: Dict[str, Any]) -> None:
|
|
|
92
92
|
for body_type in body_parameter["type"]["types"]:
|
|
93
93
|
if any(o for o in yaml_data["overloads"] if id(o["bodyParameter"]["type"]) == id(body_type)):
|
|
94
94
|
continue
|
|
95
|
-
yaml_data["overloads"].append(add_overload(yaml_data, body_type))
|
|
96
95
|
if body_type.get("type") == "model" and body_type.get("base") == "json":
|
|
97
96
|
yaml_data["overloads"].append(add_overload(yaml_data, body_type, for_flatten_params=True))
|
|
97
|
+
yaml_data["overloads"].append(add_overload(yaml_data, body_type))
|
|
98
98
|
content_type_param = next(p for p in yaml_data["parameters"] if p["wireName"].lower() == "content-type")
|
|
99
99
|
content_type_param["inOverload"] = False
|
|
100
100
|
content_type_param["inOverridden"] = True
|
|
Binary file
|
|
@@ -313,7 +313,7 @@ class CodeModel: # pylint: disable=too-many-public-methods, disable=too-many-in
|
|
|
313
313
|
:param int schema_id: The yaml id of the schema
|
|
314
314
|
:return: If created, we return the created schema, otherwise, we throw.
|
|
315
315
|
:rtype: ~autorest.models.BaseType
|
|
316
|
-
:raises
|
|
316
|
+
:raises KeyError: if schema is not found
|
|
317
317
|
"""
|
|
318
318
|
try:
|
|
319
319
|
return next(type for id, type in self.types_map.items() if id == schema_id)
|
|
@@ -47,9 +47,7 @@ from typing import (
|
|
|
47
47
|
IO,
|
|
48
48
|
Mapping,
|
|
49
49
|
Callable,
|
|
50
|
-
TypeVar,
|
|
51
50
|
MutableMapping,
|
|
52
|
-
Type,
|
|
53
51
|
List,
|
|
54
52
|
)
|
|
55
53
|
|
|
@@ -60,13 +58,13 @@ except ImportError:
|
|
|
60
58
|
import xml.etree.ElementTree as ET
|
|
61
59
|
|
|
62
60
|
import isodate # type: ignore
|
|
61
|
+
from typing_extensions import Self
|
|
63
62
|
|
|
64
63
|
from {{ code_model.core_library }}.exceptions import DeserializationError, SerializationError
|
|
65
64
|
from {{ code_model.core_library }}.serialization import NULL as CoreNull
|
|
66
65
|
|
|
67
66
|
_BOM = codecs.BOM_UTF8.decode(encoding="utf-8")
|
|
68
67
|
|
|
69
|
-
ModelType = TypeVar("ModelType", bound="Model")
|
|
70
68
|
JSON = MutableMapping[str, Any]
|
|
71
69
|
|
|
72
70
|
|
|
@@ -383,25 +381,25 @@ class Model:
|
|
|
383
381
|
return client_models
|
|
384
382
|
|
|
385
383
|
@classmethod
|
|
386
|
-
def deserialize(cls
|
|
384
|
+
def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self:
|
|
387
385
|
"""Parse a str using the RestAPI syntax and return a model.
|
|
388
386
|
|
|
389
387
|
:param str data: A str using RestAPI structure. JSON by default.
|
|
390
388
|
:param str content_type: JSON by default, set application/xml if XML.
|
|
391
389
|
:returns: An instance of this model
|
|
392
|
-
:raises
|
|
393
|
-
:rtype:
|
|
390
|
+
:raises DeserializationError: if something went wrong
|
|
391
|
+
:rtype: Self
|
|
394
392
|
"""
|
|
395
393
|
deserializer = Deserializer(cls._infer_class_models())
|
|
396
394
|
return deserializer(cls.__name__, data, content_type=content_type) # type: ignore
|
|
397
395
|
|
|
398
396
|
@classmethod
|
|
399
397
|
def from_dict(
|
|
400
|
-
cls
|
|
398
|
+
cls,
|
|
401
399
|
data: Any,
|
|
402
400
|
key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None,
|
|
403
401
|
content_type: Optional[str] = None,
|
|
404
|
-
) ->
|
|
402
|
+
) -> Self:
|
|
405
403
|
"""Parse a dict using given key extractor return a model.
|
|
406
404
|
|
|
407
405
|
By default consider key
|
|
@@ -413,7 +411,7 @@ class Model:
|
|
|
413
411
|
:param str content_type: JSON by default, set application/xml if XML.
|
|
414
412
|
:returns: An instance of this model
|
|
415
413
|
:raises: DeserializationError if something went wrong
|
|
416
|
-
:rtype:
|
|
414
|
+
:rtype: Self
|
|
417
415
|
"""
|
|
418
416
|
deserializer = Deserializer(cls._infer_class_models())
|
|
419
417
|
deserializer.key_extractors = ( # type: ignore
|
|
@@ -559,7 +557,7 @@ class Serializer: # pylint: disable=too-many-public-methods
|
|
|
559
557
|
:param object target_obj: The data to be serialized.
|
|
560
558
|
:param str data_type: The type to be serialized from.
|
|
561
559
|
:rtype: str, dict
|
|
562
|
-
:raises
|
|
560
|
+
:raises SerializationError: if serialization fails.
|
|
563
561
|
:returns: The serialized data.
|
|
564
562
|
"""
|
|
565
563
|
key_transformer = kwargs.get("key_transformer", self.key_transformer)
|
|
@@ -669,8 +667,8 @@ class Serializer: # pylint: disable=too-many-public-methods
|
|
|
669
667
|
:param object data: The data to be serialized.
|
|
670
668
|
:param str data_type: The type to be serialized from.
|
|
671
669
|
:rtype: dict
|
|
672
|
-
:raises
|
|
673
|
-
:raises
|
|
670
|
+
:raises SerializationError: if serialization fails.
|
|
671
|
+
:raises ValueError: if data is None
|
|
674
672
|
:returns: The serialized request body
|
|
675
673
|
"""
|
|
676
674
|
|
|
@@ -714,8 +712,8 @@ class Serializer: # pylint: disable=too-many-public-methods
|
|
|
714
712
|
:param str data_type: The type to be serialized from.
|
|
715
713
|
:rtype: str
|
|
716
714
|
:returns: The serialized URL path
|
|
717
|
-
:raises
|
|
718
|
-
:raises
|
|
715
|
+
:raises TypeError: if serialization fails.
|
|
716
|
+
:raises ValueError: if data is None
|
|
719
717
|
"""
|
|
720
718
|
try:
|
|
721
719
|
output = self.serialize_data(data, data_type, **kwargs)
|
|
@@ -738,8 +736,8 @@ class Serializer: # pylint: disable=too-many-public-methods
|
|
|
738
736
|
:param object data: The data to be serialized.
|
|
739
737
|
:param str data_type: The type to be serialized from.
|
|
740
738
|
:rtype: str, list
|
|
741
|
-
:raises
|
|
742
|
-
:raises
|
|
739
|
+
:raises TypeError: if serialization fails.
|
|
740
|
+
:raises ValueError: if data is None
|
|
743
741
|
:returns: The serialized query parameter
|
|
744
742
|
"""
|
|
745
743
|
try:
|
|
@@ -768,8 +766,8 @@ class Serializer: # pylint: disable=too-many-public-methods
|
|
|
768
766
|
:param object data: The data to be serialized.
|
|
769
767
|
:param str data_type: The type to be serialized from.
|
|
770
768
|
:rtype: str
|
|
771
|
-
:raises
|
|
772
|
-
:raises
|
|
769
|
+
:raises TypeError: if serialization fails.
|
|
770
|
+
:raises ValueError: if data is None
|
|
773
771
|
:returns: The serialized header
|
|
774
772
|
"""
|
|
775
773
|
try:
|
|
@@ -788,9 +786,9 @@ class Serializer: # pylint: disable=too-many-public-methods
|
|
|
788
786
|
|
|
789
787
|
:param object data: The data to be serialized.
|
|
790
788
|
:param str data_type: The type to be serialized from.
|
|
791
|
-
:raises
|
|
792
|
-
:raises
|
|
793
|
-
:raises
|
|
789
|
+
:raises AttributeError: if required data is None.
|
|
790
|
+
:raises ValueError: if data is None
|
|
791
|
+
:raises SerializationError: if serialization fails.
|
|
794
792
|
:returns: The serialized data.
|
|
795
793
|
:rtype: str, int, float, bool, dict, list
|
|
796
794
|
"""
|
|
@@ -1125,7 +1123,7 @@ class Serializer: # pylint: disable=too-many-public-methods
|
|
|
1125
1123
|
|
|
1126
1124
|
:param Datetime attr: Object to be serialized.
|
|
1127
1125
|
:rtype: str
|
|
1128
|
-
:raises
|
|
1126
|
+
:raises TypeError: if format invalid.
|
|
1129
1127
|
:return: serialized rfc
|
|
1130
1128
|
"""
|
|
1131
1129
|
try:
|
|
@@ -1151,7 +1149,7 @@ class Serializer: # pylint: disable=too-many-public-methods
|
|
|
1151
1149
|
|
|
1152
1150
|
:param Datetime attr: Object to be serialized.
|
|
1153
1151
|
:rtype: str
|
|
1154
|
-
:raises
|
|
1152
|
+
:raises SerializationError: if format invalid.
|
|
1155
1153
|
:return: serialized iso
|
|
1156
1154
|
"""
|
|
1157
1155
|
if isinstance(attr, str):
|
|
@@ -1184,7 +1182,7 @@ class Serializer: # pylint: disable=too-many-public-methods
|
|
|
1184
1182
|
|
|
1185
1183
|
:param Datetime attr: Object to be serialized.
|
|
1186
1184
|
:rtype: int
|
|
1187
|
-
:raises
|
|
1185
|
+
:raises SerializationError: if format invalid
|
|
1188
1186
|
:return: serialied unix
|
|
1189
1187
|
"""
|
|
1190
1188
|
if isinstance(attr, int):
|
|
@@ -1421,7 +1419,7 @@ class Deserializer:
|
|
|
1421
1419
|
:param str target_obj: Target data type to deserialize to.
|
|
1422
1420
|
:param requests.Response response_data: REST response object.
|
|
1423
1421
|
:param str content_type: Swagger "produces" if available.
|
|
1424
|
-
:raises
|
|
1422
|
+
:raises DeserializationError: if deserialization fails.
|
|
1425
1423
|
:return: Deserialized object.
|
|
1426
1424
|
:rtype: object
|
|
1427
1425
|
"""
|
|
@@ -1435,7 +1433,7 @@ class Deserializer:
|
|
|
1435
1433
|
|
|
1436
1434
|
:param str target_obj: Target data type to deserialize to.
|
|
1437
1435
|
:param object data: Object to deserialize.
|
|
1438
|
-
:raises
|
|
1436
|
+
:raises DeserializationError: if deserialization fails.
|
|
1439
1437
|
:return: Deserialized object.
|
|
1440
1438
|
:rtype: object
|
|
1441
1439
|
"""
|
|
@@ -1650,7 +1648,7 @@ class Deserializer:
|
|
|
1650
1648
|
|
|
1651
1649
|
:param str data: The response string to be deserialized.
|
|
1652
1650
|
:param str data_type: The type to deserialize to.
|
|
1653
|
-
:raises
|
|
1651
|
+
:raises DeserializationError: if deserialization fails.
|
|
1654
1652
|
:return: Deserialized object.
|
|
1655
1653
|
:rtype: object
|
|
1656
1654
|
"""
|
|
@@ -1732,7 +1730,7 @@ class Deserializer:
|
|
|
1732
1730
|
:param dict attr: Dictionary to be deserialized.
|
|
1733
1731
|
:return: Deserialized object.
|
|
1734
1732
|
:rtype: dict
|
|
1735
|
-
:raises
|
|
1733
|
+
:raises TypeError: if non-builtin datatype encountered.
|
|
1736
1734
|
"""
|
|
1737
1735
|
if attr is None:
|
|
1738
1736
|
return None
|
|
@@ -1778,7 +1776,7 @@ class Deserializer:
|
|
|
1778
1776
|
:param str data_type: deserialization data type.
|
|
1779
1777
|
:return: Deserialized basic type.
|
|
1780
1778
|
:rtype: str, int, float or bool
|
|
1781
|
-
:raises
|
|
1779
|
+
:raises TypeError: if string format is not valid.
|
|
1782
1780
|
"""
|
|
1783
1781
|
# If we're here, data is supposed to be a basic type.
|
|
1784
1782
|
# If it's still an XML node, take the text
|
|
@@ -1869,7 +1867,7 @@ class Deserializer:
|
|
|
1869
1867
|
:param str attr: response string to be deserialized.
|
|
1870
1868
|
:return: Deserialized bytearray
|
|
1871
1869
|
:rtype: bytearray
|
|
1872
|
-
:raises
|
|
1870
|
+
:raises TypeError: if string format invalid.
|
|
1873
1871
|
"""
|
|
1874
1872
|
if isinstance(attr, ET.Element):
|
|
1875
1873
|
attr = attr.text
|
|
@@ -1882,7 +1880,7 @@ class Deserializer:
|
|
|
1882
1880
|
:param str attr: response string to be deserialized.
|
|
1883
1881
|
:return: Deserialized base64 string
|
|
1884
1882
|
:rtype: bytearray
|
|
1885
|
-
:raises
|
|
1883
|
+
:raises TypeError: if string format invalid.
|
|
1886
1884
|
"""
|
|
1887
1885
|
if isinstance(attr, ET.Element):
|
|
1888
1886
|
attr = attr.text
|
|
@@ -1897,7 +1895,7 @@ class Deserializer:
|
|
|
1897
1895
|
|
|
1898
1896
|
:param str attr: response string to be deserialized.
|
|
1899
1897
|
:return: Deserialized decimal
|
|
1900
|
-
:raises
|
|
1898
|
+
:raises DeserializationError: if string format invalid.
|
|
1901
1899
|
:rtype: decimal
|
|
1902
1900
|
"""
|
|
1903
1901
|
if isinstance(attr, ET.Element):
|
|
@@ -1915,7 +1913,7 @@ class Deserializer:
|
|
|
1915
1913
|
:param str attr: response string to be deserialized.
|
|
1916
1914
|
:return: Deserialized int
|
|
1917
1915
|
:rtype: long or int
|
|
1918
|
-
:raises
|
|
1916
|
+
:raises ValueError: if string format invalid.
|
|
1919
1917
|
"""
|
|
1920
1918
|
if isinstance(attr, ET.Element):
|
|
1921
1919
|
attr = attr.text
|
|
@@ -1928,7 +1926,7 @@ class Deserializer:
|
|
|
1928
1926
|
:param str attr: response string to be deserialized.
|
|
1929
1927
|
:return: Deserialized duration
|
|
1930
1928
|
:rtype: TimeDelta
|
|
1931
|
-
:raises
|
|
1929
|
+
:raises DeserializationError: if string format invalid.
|
|
1932
1930
|
"""
|
|
1933
1931
|
if isinstance(attr, ET.Element):
|
|
1934
1932
|
attr = attr.text
|
|
@@ -1946,7 +1944,7 @@ class Deserializer:
|
|
|
1946
1944
|
:param str attr: response string to be deserialized.
|
|
1947
1945
|
:return: Deserialized date
|
|
1948
1946
|
:rtype: Date
|
|
1949
|
-
:raises
|
|
1947
|
+
:raises DeserializationError: if string format invalid.
|
|
1950
1948
|
"""
|
|
1951
1949
|
if isinstance(attr, ET.Element):
|
|
1952
1950
|
attr = attr.text
|
|
@@ -1962,7 +1960,7 @@ class Deserializer:
|
|
|
1962
1960
|
:param str attr: response string to be deserialized.
|
|
1963
1961
|
:return: Deserialized time
|
|
1964
1962
|
:rtype: datetime.time
|
|
1965
|
-
:raises
|
|
1963
|
+
:raises DeserializationError: if string format invalid.
|
|
1966
1964
|
"""
|
|
1967
1965
|
if isinstance(attr, ET.Element):
|
|
1968
1966
|
attr = attr.text
|
|
@@ -1977,7 +1975,7 @@ class Deserializer:
|
|
|
1977
1975
|
:param str attr: response string to be deserialized.
|
|
1978
1976
|
:return: Deserialized RFC datetime
|
|
1979
1977
|
:rtype: Datetime
|
|
1980
|
-
:raises
|
|
1978
|
+
:raises DeserializationError: if string format invalid.
|
|
1981
1979
|
"""
|
|
1982
1980
|
if isinstance(attr, ET.Element):
|
|
1983
1981
|
attr = attr.text
|
|
@@ -2000,7 +1998,7 @@ class Deserializer:
|
|
|
2000
1998
|
:param str attr: response string to be deserialized.
|
|
2001
1999
|
:return: Deserialized ISO datetime
|
|
2002
2000
|
:rtype: Datetime
|
|
2003
|
-
:raises
|
|
2001
|
+
:raises DeserializationError: if string format invalid.
|
|
2004
2002
|
"""
|
|
2005
2003
|
if isinstance(attr, ET.Element):
|
|
2006
2004
|
attr = attr.text
|
|
@@ -2038,7 +2036,7 @@ class Deserializer:
|
|
|
2038
2036
|
:param int attr: Object to be serialized.
|
|
2039
2037
|
:return: Deserialized datetime
|
|
2040
2038
|
:rtype: Datetime
|
|
2041
|
-
:raises
|
|
2039
|
+
:raises DeserializationError: if format invalid
|
|
2042
2040
|
"""
|
|
2043
2041
|
if isinstance(attr, ET.Element):
|
|
2044
2042
|
attr = int(attr.text) # type: ignore
|
|
@@ -92,9 +92,9 @@ def add_overloads_for_body_param(yaml_data: Dict[str, Any]) -> None:
|
|
|
92
92
|
for body_type in body_parameter["type"]["types"]:
|
|
93
93
|
if any(o for o in yaml_data["overloads"] if id(o["bodyParameter"]["type"]) == id(body_type)):
|
|
94
94
|
continue
|
|
95
|
-
yaml_data["overloads"].append(add_overload(yaml_data, body_type))
|
|
96
95
|
if body_type.get("type") == "model" and body_type.get("base") == "json":
|
|
97
96
|
yaml_data["overloads"].append(add_overload(yaml_data, body_type, for_flatten_params=True))
|
|
97
|
+
yaml_data["overloads"].append(add_overload(yaml_data, body_type))
|
|
98
98
|
content_type_param = next(p for p in yaml_data["parameters"] if p["wireName"].lower() == "content-type")
|
|
99
99
|
content_type_param["inOverload"] = False
|
|
100
100
|
content_type_param["inOverridden"] = True
|
|
@@ -20,8 +20,8 @@ commands =
|
|
|
20
20
|
python ../../../eng/scripts/ci/run_pyright.py -t azure -s "generated" {posargs}
|
|
21
21
|
|
|
22
22
|
# apiview
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
pip install apiview-stub-generator==0.3.13 --index-url="https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-python/pypi/simple/"
|
|
24
|
+
python ../../../eng/scripts/ci/run_apiview.py -t azure -s "generated" {posargs}
|
|
25
25
|
|
|
26
26
|
[testenv:test]
|
|
27
27
|
deps=
|
|
@@ -52,5 +52,5 @@ commands =
|
|
|
52
52
|
deps=
|
|
53
53
|
-r requirements.txt
|
|
54
54
|
commands =
|
|
55
|
-
pip install apiview-stub-generator==0.3.
|
|
55
|
+
pip install apiview-stub-generator==0.3.13 --index-url="https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-python/pypi/simple/"
|
|
56
56
|
python ../../../eng/scripts/ci/run_apiview.py -t azure -s "generated" {posargs}
|
|
@@ -20,8 +20,8 @@ commands =
|
|
|
20
20
|
python ../../../eng/scripts/ci/run_pyright.py -t unbranded -s "generated" {posargs}
|
|
21
21
|
|
|
22
22
|
# apiview
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
pip install apiview-stub-generator==0.3.13 --index-url="https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-python/pypi/simple/"
|
|
24
|
+
python ../../../eng/scripts/ci/run_apiview.py -t unbranded -s "generated" {posargs}
|
|
25
25
|
|
|
26
26
|
[testenv:test]
|
|
27
27
|
deps=
|
|
@@ -52,5 +52,5 @@ commands =
|
|
|
52
52
|
deps=
|
|
53
53
|
-r requirements.txt
|
|
54
54
|
commands =
|
|
55
|
-
pip install apiview-stub-generator==0.3.
|
|
55
|
+
pip install apiview-stub-generator==0.3.13 --index-url="https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-python/pypi/simple/"
|
|
56
56
|
python ../../../eng/scripts/ci/run_apiview.py -t unbranded -s "generated" {posargs}
|