|
5 | 5 | from typing import Optional
|
6 | 6 | from typing import Union
|
7 | 7 |
|
| 8 | +from lazy_object_proxy import Proxy |
| 9 | + |
8 | 10 | from openapi_core.exceptions import SpecError
|
9 | 11 | from openapi_core.finders import SpecClasses
|
10 | 12 | from openapi_core.finders import SpecFinder
|
@@ -317,19 +319,22 @@ def validate_request(
|
317 | 319 | if cls is None or issubclass(
|
318 | 320 | cls, (RequestUnmarshaller, WebhookRequestUnmarshaller)
|
319 | 321 | ):
|
320 |
| - warnings.warn( |
321 |
| - "validate_request is deprecated for unmarshalling data " |
322 |
| - "and it will not return any result in the future. " |
323 |
| - "Use unmarshal_request function instead.", |
324 |
| - DeprecationWarning, |
325 |
| - ) |
326 |
| - return unmarshal_request( |
| 322 | + result = unmarshal_request( |
327 | 323 | request,
|
328 | 324 | spec=spec,
|
329 | 325 | base_url=base_url,
|
330 | 326 | cls=cls,
|
331 | 327 | **validator_kwargs,
|
332 | 328 | )
|
| 329 | + def return_result() -> RequestUnmarshalResult: |
| 330 | + warnings.warn( |
| 331 | + "validate_request is deprecated for unmarshalling data " |
| 332 | + "and it will not return any result in the future. " |
| 333 | + "Use unmarshal_request function instead.", |
| 334 | + DeprecationWarning, |
| 335 | + ) |
| 336 | + return result |
| 337 | + return Proxy(return_result) # type: ignore |
333 | 338 | if isinstance(request, WebhookRequest):
|
334 | 339 | if cls is None or issubclass(cls, WebhookRequestValidator):
|
335 | 340 | validate_webhook_request(
|
@@ -400,20 +405,23 @@ def validate_response(
|
400 | 405 | if cls is None or issubclass(
|
401 | 406 | cls, (ResponseUnmarshaller, WebhookResponseUnmarshaller)
|
402 | 407 | ):
|
403 |
| - warnings.warn( |
404 |
| - "validate_response is deprecated for unmarshalling data " |
405 |
| - "and it will not return any result in the future. " |
406 |
| - "Use unmarshal_response function instead.", |
407 |
| - DeprecationWarning, |
408 |
| - ) |
409 |
| - return unmarshal_response( |
| 408 | + result = unmarshal_response( |
410 | 409 | request,
|
411 | 410 | response,
|
412 | 411 | spec=spec,
|
413 | 412 | base_url=base_url,
|
414 | 413 | cls=cls,
|
415 | 414 | **validator_kwargs,
|
416 | 415 | )
|
| 416 | + def return_result() -> ResponseUnmarshalResult: |
| 417 | + warnings.warn( |
| 418 | + "validate_response is deprecated for unmarshalling data " |
| 419 | + "and it will not return any result in the future. " |
| 420 | + "Use unmarshal_response function instead.", |
| 421 | + DeprecationWarning, |
| 422 | + ) |
| 423 | + return result |
| 424 | + return Proxy(return_result) # type: ignore |
417 | 425 | if isinstance(request, WebhookRequest):
|
418 | 426 | if cls is None or issubclass(cls, WebhookResponseValidator):
|
419 | 427 | validate_webhook_response(
|
|
0 commit comments