An exception is raised when using the validate_response decorator with a header class argument set to a class that inherits from a pydantic base model instead of a dataclass or dictionary.
class TestModel(BaseModel):
id: int
class TestHeaders(BaseModel):
content_type: str = Field(default = 'text/html', const = True, alias = 'content-type')
@validate_response(TestModel, 200, TestHeaders)
def test_endpoint():
model = TestModel(id = 1)
headers = TestHeaders()
return model, 200, headers
During request execution a ResponseHeadersValidationError exception will be raised on line 243 of validation.py.
The issue seems to be that the line is incorrectly checking the type of the value model against the expected header class:
An exception is raised when using the
validate_response
decorator with a header class argument set to a class that inherits from a pydantic base model instead of a dataclass or dictionary.During request execution a
ResponseHeadersValidationError
exception will be raised on line 243 ofvalidation.py
.The issue seems to be that the line is incorrectly checking the type of the value model against the expected header class:
when it should instead be checking the type of the provided headers against the expected header class: