Open
Description
Actual Behavior
If I write an OpenAPI document that specifies a parameter foo
that’s deprecated: true
, and use it to validate a request that does not include that parameter, openapi-core still raises DeprecationWarning: foo parameter is deprecated
for no reason.
Expected Behavior
No DeprecationWarning
should be raised.
I don’t think DeprecationWarning
is appropriate at all here, as a DeprecationWarning
is one that’s “intended for other Python developers” and not for users of a network API. But at the least, it’s obviously inappropriate when the parameter being warned about was not even provided.
Steps to Reproduce
Run with python -Werror
(or in another way that enables warnings, such as development mode):
from openapi_core import OpenAPI
from openapi_core.testing import MockRequest
spec = OpenAPI.from_dict(
{
"openapi": "3.1.0",
"info": {"version": "0", "title": "test"},
"paths": {
"/test": {
"get": {
"parameters": [
{
"name": "foo",
"in": "query",
"schema": {},
"deprecated": True,
},
],
},
},
},
}
)
spec.validate_request(MockRequest("http://localhost", "get", "/test"))
Traceback (most recent call last):
File "/home/anders/python/openapi-core/deprecated_test.py", line 24, in <module>
spec.validate_request(MockRequest("http://localhost", "get", "/test"))
File "/home/anders/python/openapi-core/openapi_core/app.py", line 360, in validate_request
self.validate_apicall_request(request)
File "/home/anders/python/openapi-core/openapi_core/app.py", line 373, in validate_apicall_request
self.request_validator.validate(request)
File "/home/anders/python/openapi-core/openapi_core/validation/request/validators.py", line 286, in validate
for err in self.iter_errors(request):
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/anders/python/openapi-core/openapi_core/validation/request/validators.py", line 349, in iter_errors
yield from self._iter_errors(request, operation, path)
File "/home/anders/python/openapi-core/openapi_core/validation/request/validators.py", line 115, in _iter_errors
self._get_parameters(request.parameters, operation, path)
File "/home/anders/python/openapi-core/openapi_core/validation/request/validators.py", line 172, in _get_parameters
value = self._get_parameter(parameters, param)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/anders/python/openapi-core/openapi_core/validation/decorators.py", line 31, in wrapper
return f(*args, **kwds)
^^^^^^^^^^^^^^^^
File "/home/anders/python/openapi-core/openapi_core/validation/request/validators.py", line 199, in _get_parameter
warnings.warn(
DeprecationWarning: foo parameter is deprecated
OpenAPI Core Version
0.19.4
OpenAPI Core Integration
none
Affected Area(s)
No response
References
validation
Anything else we need to know?
No response
Would you like to implement a fix?
None