@autorest/python 6.13.13 → 6.13.14
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.
|
@@ -59,6 +59,10 @@ OperationType = TypeVar(
|
|
|
59
59
|
)
|
|
60
60
|
|
|
61
61
|
|
|
62
|
+
def _json_serializable(content_type: str) -> bool:
|
|
63
|
+
return bool(JSON_REGEXP.match(content_type.split(";")[0].strip().lower()))
|
|
64
|
+
|
|
65
|
+
|
|
62
66
|
def _need_type_ignore(builder: OperationType) -> bool:
|
|
63
67
|
for excep in builder.non_default_errors:
|
|
64
68
|
for status_code in excep.status_codes:
|
|
@@ -813,7 +817,7 @@ class _OperationSerializer(
|
|
|
813
817
|
f"'{body_param.type.serialization_type}'{is_xml_cmd}{serialization_ctxt_cmd})"
|
|
814
818
|
)
|
|
815
819
|
elif self.code_model.options["models_mode"] == "dpg":
|
|
816
|
-
if
|
|
820
|
+
if _json_serializable(body_param.default_content_type):
|
|
817
821
|
if hasattr(body_param.type, "encode") and body_param.type.encode: # type: ignore
|
|
818
822
|
create_body_call = (
|
|
819
823
|
f"_{body_kwarg_name} = json.dumps({body_param.client_name}, "
|
|
@@ -1157,7 +1161,7 @@ class _OperationSerializer(
|
|
|
1157
1161
|
)
|
|
1158
1162
|
response_attr = (
|
|
1159
1163
|
"json"
|
|
1160
|
-
if
|
|
1164
|
+
if _json_serializable(str(response.default_content_type))
|
|
1161
1165
|
else "text"
|
|
1162
1166
|
)
|
|
1163
1167
|
deserialize_code.append("deserialized = _deserialize(")
|