Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Bug]: RaisesDeprecationWarning for deprecated parameters that were not provided #931

Open
Labels
kind/bugIndicates an issue
@andersk

Description

@andersk

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugIndicates an issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp