|
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,24 @@ 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 | + |
| 330 | + def return_result() -> RequestUnmarshalResult: |
| 331 | + warnings.warn( |
| 332 | + "validate_request is deprecated for unmarshalling data " |
| 333 | + "and it will not return any result in the future. " |
| 334 | + "Use unmarshal_request function instead.", |
| 335 | + DeprecationWarning, |
| 336 | + ) |
| 337 | + return result |
| 338 | + |
| 339 | + return Proxy(return_result) # type: ignore |
333 | 340 | if isinstance(request, WebhookRequest): |
334 | 341 | if cls is None or issubclass(cls, WebhookRequestValidator): |
335 | 342 | validate_webhook_request( |
@@ -400,20 +407,25 @@ def validate_response( |
400 | 407 | if cls is None or issubclass( |
401 | 408 | cls, (ResponseUnmarshaller, WebhookResponseUnmarshaller) |
402 | 409 | ): |
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( |
| 410 | + result = unmarshal_response( |
410 | 411 | request, |
411 | 412 | response, |
412 | 413 | spec=spec, |
413 | 414 | base_url=base_url, |
414 | 415 | cls=cls, |
415 | 416 | **validator_kwargs, |
416 | 417 | ) |
| 418 | + |
| 419 | + def return_result() -> ResponseUnmarshalResult: |
| 420 | + warnings.warn( |
| 421 | + "validate_response is deprecated for unmarshalling data " |
| 422 | + "and it will not return any result in the future. " |
| 423 | + "Use unmarshal_response function instead.", |
| 424 | + DeprecationWarning, |
| 425 | + ) |
| 426 | + return result |
| 427 | + |
| 428 | + return Proxy(return_result) # type: ignore |
417 | 429 | if isinstance(request, WebhookRequest): |
418 | 430 | if cls is None or issubclass(cls, WebhookResponseValidator): |
419 | 431 | validate_webhook_response( |
|
0 commit comments