openapi-core icon indicating copy to clipboard operation
openapi-core copied to clipboard

[Bug]: PathNotFound exception if templated path parameter contains "-" character

Open balchugovg opened this issue 1 year ago • 1 comments

Actual Behavior

when trying to validate my request, I encountered an error: ..\venv\Lib\site-packages\openapi_core\templating\paths\finders.py:35: PathNotFound

seems to be a problem with the search function from openapi_core.templating.util

Expected Behavior

print(search(path_pattern_fail, name)) # <Result () {'user-id': '1647222638'}>

Steps to Reproduce

from openapi_core.templating.util import search

path_pattern_pass = '/local/sub/{user_id}/duration'
path_pattern_fail = '/local/sub/{user-id}/duration'
name = 'https://dummy_server.com/local/sub/1647222638/duration'

print(search(path_pattern_pass, name))  # <Result () {'user_id': '1647222638'}>
print(search(path_pattern_fail, name))  # None

OpenAPI Core Version

0.18.1

OpenAPI Core Integration

Requests

Affected Area(s)

No response

References

No response

Anything else we need to know?

No response

Would you like to implement a fix?

None

balchugovg avatar Sep 20 '23 00:09 balchugovg

Hi @balchugovg

thanks for the report. I'm aware of the limitation of current template variables search mechanism, unfortunately I have limited knowledge in python Parser area to fix the issue so for now - and ~ special characters are not supported in path parameters.

p1c2u avatar Sep 25 '23 14:09 p1c2u