Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
5 changes: 5 additions & 0 deletions openapi_core/contrib/django/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ openapi-schema-validator
six
lazy-object-proxy
attrs
parse==1.14.0
parse==1.19.0
more-itertools>=5.0.0
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'djangotest.urls'
ROOT_URLCONF = 'djangoproject.urls'

TEMPLATES = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

class TestView(APIView):

def get(self, request, pk):
def get(self, request, pk=None):
with open(settings.OPENAPI_SPEC_PATH) as file:
spec_yaml = file.read()
spec_dict = yaml.load(spec_yaml)
spec_dict = yaml.safe_load(spec_yaml)
spec = create_spec(spec_dict)

openapi_request = DjangoOpenAPIRequest(request)
Expand Down
5 changes: 3 additions & 2 deletions tests/integration/contrib/django/data/djangoproject/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import include, path
from djangotest.testapp import views
from django.urls import include, path, re_path
from djangoproject.testapp import views

urlpatterns = [
path('admin/', admin.site.urls),
Expand All @@ -28,4 +28,5 @@
views.TestView.as_view(),
name='test',
),
re_path(r"^api/test-regexp/$", views.TestView.as_view()),
]
10 changes: 10 additions & 0 deletions tests/integration/contrib/django/data/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,13 @@ paths:
schema:
type: integer
minimum: 1

/api/test-simple/:
get:
responses:
'200':
description: Success.
content:
application/json:
schema:
type: object
16 changes: 16 additions & 0 deletions tests/integration/contrib/django/test_django_core_apiview.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import pytest

from six import b


class TestDjangoRESTFrameworkAPIView(object):

@pytest.fixture
def http_client(self):
from django.test import Client
return Client()

def test_get(self, http_client):
response = http_client.get('/api/test-simple/')

assert response.content == b('{"test": "test_val"}')