-
-
Notifications
You must be signed in to change notification settings - Fork 136
Closed
Labels
Description
This succeeds in 0.13.8 and unexpectedly raises KeyError: 'type'
in 0.14.0. I bisected the problem to commit 35f8e28 “Spec path”.
from openapi_core import create_spec
from openapi_core.testing import MockRequest
from openapi_core.validation.request.validators import RequestValidator
spec = create_spec(
{
"openapi": "3.0.0",
"info": {"title": "test", "version": "0"},
"paths": {
"/messages": {
"get": {
"parameters": [
{
"name": "anchor",
"in": "query",
"schema": {
"oneOf": [{"type": "string"}, {"type": "integer"}]
},
}
],
"responses": {"200": {"description": "Success."}},
}
}
},
},
)
validator = RequestValidator(spec)
request = MockRequest(
"http://localhost", "GET", "/messages", args={"anchor": "first_unread"}
)
result = validator.validate(request)
result.raise_for_errors()
Traceback (most recent call last):
File "oneof_test.py", line 31, in <module>
result = validator.validate(request)
File "/home/anders/python/openapi-core/openapi_core/validation/request/validators.py", line 48, in validate
params, params_errors = self._get_parameters(
File "/home/anders/python/openapi-core/openapi_core/validation/request/validators.py", line 138, in _get_parameters
raw_value = self._get_parameter_value(param, request)
File "/home/anders/python/openapi-core/openapi_core/validation/request/validators.py", line 226, in _get_parameter_value
aslist = get_aslist(param)
File "/home/anders/python/openapi-core/openapi_core/schema/parameters.py", line 4, in get_aslist
param['schema']['type'] in ['array', 'object']
KeyError: 'type'