diff --git a/src/OpenApiLibCore/openapi_libcore.py b/src/OpenApiLibCore/openapi_libcore.py index 39f96d1..e0bebc5 100644 --- a/src/OpenApiLibCore/openapi_libcore.py +++ b/src/OpenApiLibCore/openapi_libcore.py @@ -131,7 +131,7 @@ from typing import Any, Dict, List, Optional, Set, Tuple, Type, Union from uuid import uuid4 -from openapi_core import Spec, validate_response +from openapi_core import Config, OpenAPI, Spec from openapi_core.contrib.requests import ( RequestsOpenAPIRequest, RequestsOpenAPIResponse, @@ -633,10 +633,14 @@ def validate_response_vs_spec( Validate the reponse for a given request against the OpenAPI Spec that is loaded during library initialization. """ - _ = validate_response( - spec=self.validation_spec, - request=request, - response=response, + if response.content_type == "application/json": + config = None + else: + extra_deserializer = {response.content_type: _json.loads} + config = Config(extra_media_type_deserializers=extra_deserializer) + + OpenAPI(spec=self.validation_spec, config=config).validate_response( + request, response ) @keyword