Skip to content

Commit

Permalink
Merge pull request #12 from MarketSquare/support_additional_json_mime…
Browse files Browse the repository at this point in the history
…_types

support extra json mime types in spec validation
  • Loading branch information
robinmackaij authored Apr 5, 2024
2 parents 4ce6e97 + 82aa33d commit 44c41d6
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/OpenApiLibCore/openapi_libcore.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 44c41d6

Please sign in to comment.