Content-Length: 4831 | pFad | http://github.com/python-openapi/openapi-core/pull/337.patch

thub.com From 1f1c0182710f002d7c05aa310a03480ed11402a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Bregu=C5=82a?= Date: Sat, 22 May 2021 00:06:09 +0200 Subject: [PATCH 1/3] Support basic re_path --- openapi_core/contrib/django/requests.py | 5 +++++ tests/integration/contrib/test_django.py | 28 +++++++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/openapi_core/contrib/django/requests.py b/openapi_core/contrib/django/requests.py index 9058be51..16dd2d00 100644 --- a/openapi_core/contrib/django/requests.py +++ b/openapi_core/contrib/django/requests.py @@ -36,6 +36,11 @@ def create(cls, request): else: route = cls.path_regex.sub( r'{\1}', request.resolver_match.route) + # Delete start marker and expression marker to allow concatenation. + if route[:1] == "^": + route = route[1:] + if route[-1:] == "$": + route = route[:-1] path_pattern = '/' + route path = request.resolver_match and request.resolver_match.kwargs or {} diff --git a/tests/integration/contrib/test_django.py b/tests/integration/contrib/test_django.py index e23bfc19..fc775776 100644 --- a/tests/integration/contrib/test_django.py +++ b/tests/integration/contrib/test_django.py @@ -19,7 +19,7 @@ def django_settings(self): import django from django.conf import settings from django.contrib import admin - from django.urls import path + from django.urls import path, re_path if settings.configured: return @@ -44,6 +44,7 @@ def django_settings(self): django.setup() settings.ROOT_URLCONF = ( path('admin/', admin.site.urls), + re_path('test/test-regexp/$', lambda d: None) ) @pytest.fixture @@ -138,6 +139,31 @@ def test_url_rule(self, request_factory): assert openapi_request.body == request.body assert openapi_request.mimetype == request.content_type + def test_url_regexp_pattern(self, request_factory): + from django.urls import resolve + request = request_factory.get('/test/test-regexp/') + request.resolver_match = resolve('/test/test-regexp/') + + openapi_request = DjangoOpenAPIRequest(request) + + path = {} + query = {} + headers = { + 'Cookie': '', + } + cookies = {} + assert openapi_request.parameters == RequestParameters( + path=path, + query=query, + header=headers, + cookie=cookies, + ) + assert openapi_request.method == request.method.lower() + assert openapi_request.full_url_pattern == \ + request._current_scheme_host + "/test/test-regexp/" + assert openapi_request.body == request.body + assert openapi_request.mimetype == request.content_type + class TestDjangoOpenAPIResponse(BaseTestDjango): From ee09bfbde706d4d4efe0ea2f5b746281903d7a9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Bregu=C5=82a?= Date: Sun, 23 May 2021 01:11:24 +0200 Subject: [PATCH 2/3] fixup! Support basic re_path --- tests/integration/contrib/test_django.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/contrib/test_django.py b/tests/integration/contrib/test_django.py index fc775776..61d8f676 100644 --- a/tests/integration/contrib/test_django.py +++ b/tests/integration/contrib/test_django.py @@ -44,7 +44,7 @@ def django_settings(self): django.setup() settings.ROOT_URLCONF = ( path('admin/', admin.site.urls), - re_path('test/test-regexp/$', lambda d: None) + re_path('^test/test-regexp/$', lambda d: None) ) @pytest.fixture From ff4d852d1c5456b60b5519c31ff396bf631dffcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Bregu=C5=82a?= Date: Sun, 23 May 2021 01:15:36 +0200 Subject: [PATCH 3/3] fixup! fixup! Support basic re_path --- openapi_core/contrib/django/requests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openapi_core/contrib/django/requests.py b/openapi_core/contrib/django/requests.py index 16dd2d00..4a41bafd 100644 --- a/openapi_core/contrib/django/requests.py +++ b/openapi_core/contrib/django/requests.py @@ -36,7 +36,7 @@ def create(cls, request): else: route = cls.path_regex.sub( r'{\1}', request.resolver_match.route) - # Delete start marker and expression marker to allow concatenation. + # Delete start and end marker to allow concatenation. if route[:1] == "^": route = route[1:] if route[-1:] == "$":








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/python-openapi/openapi-core/pull/337.patch

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy