Skip to content

Commit 2aeac4b

Browse files
authored
[python] fix failsafe deserialize for swagger generation (#3235)
* update regenerate.ts * Update dependencies * Update dependencies (2025-10-09 05:26:38) * Regenerate for typespec-python (2025-10-09 05:31:40) * open test case * add changelog * bump version * update lock file * bump dep * Regenerate for typespec-python (2025-10-11 05:52:56) * Regenerate for autorest.python (2025-10-11 06:07:23) * Fix failsafe deserialize for swagger generation --------- Co-authored-by: AutoPrFromHttpClientPython <AutoPrFromHttpClientPython>
1 parent 2e44ba4 commit 2aeac4b

172 files changed

Lines changed: 6875 additions & 1724 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
changeKind: internal
3+
packages:
4+
- "@autorest/python"
5+
- "@azure-tools/typespec-python"
6+
---
7+
8+
Fix failsafe deserialize for swagger generation

packages/autorest.python/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
},
3030
"homepage": "https://github.com/Azure/autorest.python/blob/main/README.md",
3131
"dependencies": {
32-
"@typespec/http-client-python": "~0.19.1",
32+
"@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNTQzNDg4MC9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.19.1.tgz",
3333
"@autorest/system-requirements": "~1.0.2",
3434
"fs-extra": "~11.2.0",
3535
"tsx": "~4.19.1"

packages/autorest.python/samples/specification/azure-test/test/azure-test/azure/test/_generated/aio/operations/_operations.py

Lines changed: 276 additions & 69 deletions
Large diffs are not rendered by default.

packages/autorest.python/samples/specification/azure-test/test/azure-test/azure/test/_generated/operations/_operations.py

Lines changed: 276 additions & 69 deletions
Large diffs are not rendered by default.

packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/aio/operations/_duration_operations.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,10 @@ async def get_null(self, **kwargs: Any) -> Optional[datetime.timedelta]:
9494

9595
if response.status_code not in [200]:
9696
map_error(status_code=response.status_code, response=response, error_map=error_map)
97-
error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response)
97+
error = self._deserialize.failsafe_deserialize(
98+
_models.Error,
99+
pipeline_response,
100+
)
98101
raise HttpResponseError(response=response, model=error)
99102

100103
deserialized = self._deserialize("duration", pipeline_response.http_response)
@@ -147,7 +150,10 @@ async def put_positive_duration(self, duration_body: datetime.timedelta, **kwarg
147150

148151
if response.status_code not in [200]:
149152
map_error(status_code=response.status_code, response=response, error_map=error_map)
150-
error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response)
153+
error = self._deserialize.failsafe_deserialize(
154+
_models.Error,
155+
pipeline_response,
156+
)
151157
raise HttpResponseError(response=response, model=error)
152158

153159
if cls:
@@ -189,7 +195,10 @@ async def get_positive_duration(self, **kwargs: Any) -> datetime.timedelta:
189195

190196
if response.status_code not in [200]:
191197
map_error(status_code=response.status_code, response=response, error_map=error_map)
192-
error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response)
198+
error = self._deserialize.failsafe_deserialize(
199+
_models.Error,
200+
pipeline_response,
201+
)
193202
raise HttpResponseError(response=response, model=error)
194203

195204
deserialized = self._deserialize("duration", pipeline_response.http_response)
@@ -235,7 +244,10 @@ async def get_invalid(self, **kwargs: Any) -> datetime.timedelta:
235244

236245
if response.status_code not in [200]:
237246
map_error(status_code=response.status_code, response=response, error_map=error_map)
238-
error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response)
247+
error = self._deserialize.failsafe_deserialize(
248+
_models.Error,
249+
pipeline_response,
250+
)
239251
raise HttpResponseError(response=response, model=error)
240252

241253
deserialized = self._deserialize("duration", pipeline_response.http_response)

packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/operations/_duration_operations.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,10 @@ def get_null(self, **kwargs: Any) -> Optional[datetime.timedelta]:
150150

151151
if response.status_code not in [200]:
152152
map_error(status_code=response.status_code, response=response, error_map=error_map)
153-
error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response)
153+
error = self._deserialize.failsafe_deserialize(
154+
_models.Error,
155+
pipeline_response,
156+
)
154157
raise HttpResponseError(response=response, model=error)
155158

156159
deserialized = self._deserialize("duration", pipeline_response.http_response)
@@ -205,7 +208,10 @@ def put_positive_duration( # pylint: disable=inconsistent-return-statements
205208

206209
if response.status_code not in [200]:
207210
map_error(status_code=response.status_code, response=response, error_map=error_map)
208-
error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response)
211+
error = self._deserialize.failsafe_deserialize(
212+
_models.Error,
213+
pipeline_response,
214+
)
209215
raise HttpResponseError(response=response, model=error)
210216

211217
if cls:
@@ -247,7 +253,10 @@ def get_positive_duration(self, **kwargs: Any) -> datetime.timedelta:
247253

248254
if response.status_code not in [200]:
249255
map_error(status_code=response.status_code, response=response, error_map=error_map)
250-
error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response)
256+
error = self._deserialize.failsafe_deserialize(
257+
_models.Error,
258+
pipeline_response,
259+
)
251260
raise HttpResponseError(response=response, model=error)
252261

253262
deserialized = self._deserialize("duration", pipeline_response.http_response)
@@ -293,7 +302,10 @@ def get_invalid(self, **kwargs: Any) -> datetime.timedelta:
293302

294303
if response.status_code not in [200]:
295304
map_error(status_code=response.status_code, response=response, error_map=error_map)
296-
error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response)
305+
error = self._deserialize.failsafe_deserialize(
306+
_models.Error,
307+
pipeline_response,
308+
)
297309
raise HttpResponseError(response=response, model=error)
298310

299311
deserialized = self._deserialize("duration", pipeline_response.http_response)

packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/aio/operations/_parameter_grouping_operations.py

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,10 @@ async def post_required(
120120

121121
if response.status_code not in [200]:
122122
map_error(status_code=response.status_code, response=response, error_map=error_map)
123-
error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response)
123+
error = self._deserialize.failsafe_deserialize(
124+
_models.Error,
125+
pipeline_response,
126+
)
124127
raise HttpResponseError(response=response, model=error)
125128

126129
if cls:
@@ -177,7 +180,10 @@ async def post_optional(
177180

178181
if response.status_code not in [200]:
179182
map_error(status_code=response.status_code, response=response, error_map=error_map)
180-
error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response)
183+
error = self._deserialize.failsafe_deserialize(
184+
_models.Error,
185+
pipeline_response,
186+
)
181187
raise HttpResponseError(response=response, model=error)
182188

183189
if cls:
@@ -237,7 +243,10 @@ async def post_reserved_words(
237243

238244
if response.status_code not in [200]:
239245
map_error(status_code=response.status_code, response=response, error_map=error_map)
240-
error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response)
246+
error = self._deserialize.failsafe_deserialize(
247+
_models.Error,
248+
pipeline_response,
249+
)
241250
raise HttpResponseError(response=response, model=error)
242251

243252
if cls:
@@ -307,7 +316,10 @@ async def post_multi_param_groups(
307316

308317
if response.status_code not in [200]:
309318
map_error(status_code=response.status_code, response=response, error_map=error_map)
310-
error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response)
319+
error = self._deserialize.failsafe_deserialize(
320+
_models.Error,
321+
pipeline_response,
322+
)
311323
raise HttpResponseError(response=response, model=error)
312324

313325
if cls:
@@ -361,7 +373,10 @@ async def post_shared_parameter_group_object(
361373

362374
if response.status_code not in [200]:
363375
map_error(status_code=response.status_code, response=response, error_map=error_map)
364-
error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response)
376+
error = self._deserialize.failsafe_deserialize(
377+
_models.Error,
378+
pipeline_response,
379+
)
365380
raise HttpResponseError(response=response, model=error)
366381

367382
if cls:
@@ -414,7 +429,10 @@ async def group_with_constant(self, grouper: Optional[_models.Grouper] = None, *
414429

415430
if response.status_code not in [200]:
416431
map_error(status_code=response.status_code, response=response, error_map=error_map)
417-
error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response)
432+
error = self._deserialize.failsafe_deserialize(
433+
_models.Error,
434+
pipeline_response,
435+
)
418436
raise HttpResponseError(response=response, model=error)
419437

420438
if cls:

packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureParameterGrouping/azureparametergrouping/operations/_parameter_grouping_operations.py

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,10 @@ def post_required( # pylint: disable=inconsistent-return-statements
264264

265265
if response.status_code not in [200]:
266266
map_error(status_code=response.status_code, response=response, error_map=error_map)
267-
error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response)
267+
error = self._deserialize.failsafe_deserialize(
268+
_models.Error,
269+
pipeline_response,
270+
)
268271
raise HttpResponseError(response=response, model=error)
269272

270273
if cls:
@@ -321,7 +324,10 @@ def post_optional( # pylint: disable=inconsistent-return-statements
321324

322325
if response.status_code not in [200]:
323326
map_error(status_code=response.status_code, response=response, error_map=error_map)
324-
error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response)
327+
error = self._deserialize.failsafe_deserialize(
328+
_models.Error,
329+
pipeline_response,
330+
)
325331
raise HttpResponseError(response=response, model=error)
326332

327333
if cls:
@@ -381,7 +387,10 @@ def post_reserved_words( # pylint: disable=inconsistent-return-statements
381387

382388
if response.status_code not in [200]:
383389
map_error(status_code=response.status_code, response=response, error_map=error_map)
384-
error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response)
390+
error = self._deserialize.failsafe_deserialize(
391+
_models.Error,
392+
pipeline_response,
393+
)
385394
raise HttpResponseError(response=response, model=error)
386395

387396
if cls:
@@ -451,7 +460,10 @@ def post_multi_param_groups( # pylint: disable=inconsistent-return-statements
451460

452461
if response.status_code not in [200]:
453462
map_error(status_code=response.status_code, response=response, error_map=error_map)
454-
error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response)
463+
error = self._deserialize.failsafe_deserialize(
464+
_models.Error,
465+
pipeline_response,
466+
)
455467
raise HttpResponseError(response=response, model=error)
456468

457469
if cls:
@@ -505,7 +517,10 @@ def post_shared_parameter_group_object( # pylint: disable=inconsistent-return-s
505517

506518
if response.status_code not in [200]:
507519
map_error(status_code=response.status_code, response=response, error_map=error_map)
508-
error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response)
520+
error = self._deserialize.failsafe_deserialize(
521+
_models.Error,
522+
pipeline_response,
523+
)
509524
raise HttpResponseError(response=response, model=error)
510525

511526
if cls:
@@ -560,7 +575,10 @@ def group_with_constant( # pylint: disable=inconsistent-return-statements
560575

561576
if response.status_code not in [200]:
562577
map_error(status_code=response.status_code, response=response, error_map=error_map)
563-
error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response)
578+
error = self._deserialize.failsafe_deserialize(
579+
_models.Error,
580+
pipeline_response,
581+
)
564582
raise HttpResponseError(response=response, model=error)
565583

566584
if cls:

packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/aio/operations/_auto_rest_report_service_for_azure_operations.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,10 @@ async def get_report(self, qualifier: Optional[str] = None, **kwargs: Any) -> di
7676

7777
if response.status_code not in [200]:
7878
map_error(status_code=response.status_code, response=response, error_map=error_map)
79-
error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response)
79+
error = self._deserialize.failsafe_deserialize(
80+
_models.Error,
81+
pipeline_response,
82+
)
8083
raise HttpResponseError(response=response, model=error)
8184

8285
deserialized = self._deserialize("{int}", pipeline_response.http_response)

packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/operations/_auto_rest_report_service_for_azure_operations.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,10 @@ def get_report(self, qualifier: Optional[str] = None, **kwargs: Any) -> dict[str
9898

9999
if response.status_code not in [200]:
100100
map_error(status_code=response.status_code, response=response, error_map=error_map)
101-
error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response)
101+
error = self._deserialize.failsafe_deserialize(
102+
_models.Error,
103+
pipeline_response,
104+
)
102105
raise HttpResponseError(response=response, model=error)
103106

104107
deserialized = self._deserialize("{int}", pipeline_response.http_response)

0 commit comments

Comments
 (0)