Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork135
Description
Actual Behavior
If I write an OpenAPI document that specifies a parameterfoo that’sdeprecated: true, and use it to validate a request thatdoes not include that parameter, openapi-core still raisesDeprecationWarning: foo parameter is deprecated for no reason.
Expected Behavior
NoDeprecationWarning should be raised.
I don’t thinkDeprecationWarning is appropriate at all here, as aDeprecationWarning 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 withpython -Werror (or in another way that enables warnings, such asdevelopment 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", line24, in<module> spec.validate_request(MockRequest("http://localhost","get","/test")) File"/home/anders/python/openapi-core/openapi_core/app.py", line360, invalidate_requestself.validate_apicall_request(request) File"/home/anders/python/openapi-core/openapi_core/app.py", line373, invalidate_apicall_requestself.request_validator.validate(request) File"/home/anders/python/openapi-core/openapi_core/validation/request/validators.py", line286, invalidatefor errinself.iter_errors(request):^^^^^^^^^^^^^^^^^^^^^^^^^ File"/home/anders/python/openapi-core/openapi_core/validation/request/validators.py", line349, initer_errorsyield fromself._iter_errors(request, operation, path) File"/home/anders/python/openapi-core/openapi_core/validation/request/validators.py", line115, in_iter_errorsself._get_parameters(request.parameters, operation, path) File"/home/anders/python/openapi-core/openapi_core/validation/request/validators.py", line172, in_get_parameters value=self._get_parameter(parameters, param)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File"/home/anders/python/openapi-core/openapi_core/validation/decorators.py", line31, inwrapperreturn f(*args,**kwds)^^^^^^^^^^^^^^^^ File"/home/anders/python/openapi-core/openapi_core/validation/request/validators.py", line199, 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