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):
fromopenapi_coreimportOpenAPIfromopenapi_core.testingimportMockRequestspec=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_requestself.validate_apicall_request(request)
File "/home/anders/python/openapi-core/openapi_core/app.py", line 373, in validate_apicall_requestself.request_validator.validate(request)
File "/home/anders/python/openapi-core/openapi_core/validation/request/validators.py", line 286, in validatefor err inself.iter_errors(request):
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/anders/python/openapi-core/openapi_core/validation/request/validators.py", line 349, in iter_errorsyield fromself._iter_errors(request, operation, path)
File "/home/anders/python/openapi-core/openapi_core/validation/request/validators.py", line 115, in _iter_errorsself._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 wrapperreturn 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 deprecatedOpenAPI 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
Actual Behavior
If I write an OpenAPI document that specifies a parameter
foothat’sdeprecated: true, and use it to validate a request that does not include that parameter, openapi-core still raisesDeprecationWarning: foo parameter is deprecatedfor no reason.Expected Behavior
No
DeprecationWarningshould be raised.I don’t think
DeprecationWarningis appropriate at all here, as aDeprecationWarningis 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):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