Skip to content

Incorrect django request validation for re_path urls #278

Description

@mnowakowska

When I'm trying to validate a django request against the defined schema I'm getting a validation error.

E           openapi_core.templating.paths.exceptions.PathNotFound: Path not found for https://brown.org/^my/url/$

../.pyenv/versions/3.9.0/envs/venv3.9.0/lib/python3.9/site-packages/openapi_core/templating/paths/finders.py:24:PathNotFound

My django url definition: re_path(r'^my/url/$', view())
My openapi schema url: /my/url/

I've debbugged a bit this issue and:
value of this line should be: 'my/url/'
but currently is '^my/url/$'

The value of request.resolver_match.route in my case is '^my/url/$'

I think the PATH_PARAMETER_PATTERN regex should be adjusted to escape also special characters like ^ and $ from request.resolver_match.route value

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions