Skip to content

Commit 416ca3f

Browse files
committed
Note dependency on uritemplate.
1 parent 4c17319 commit 416ca3f

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

rest_framework/schemas/inspectors.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,8 @@ def get_path_parameters(self, path, method):
511511
"""
512512
Return a list of parameters from templated path variables.
513513
"""
514+
assert uritemplate, '`uritemplate` must be installed for OpenAPI schema support.'
515+
514516
model = getattr(getattr(self.view, 'queryset', None), 'model', None)
515517
parameters = []
516518

tests/schemas/test_openapi.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
import unittest
2+
13
from django.conf.urls import url
24
from django.test import RequestFactory, TestCase, override_settings
35

6+
from rest_framework.compat import uritemplate
47
from rest_framework.request import Request
58
from rest_framework.schemas.generators import OpenAPISchemaGenerator
69
from rest_framework.schemas.inspectors import OpenAPIAutoSchema
@@ -20,6 +23,7 @@ def create_view(view_cls, method, request):
2023
return view
2124

2225

26+
@unittest.skipUnless(uritemplate, 'uritemplate is not installed')
2327
class TestOperationIntrospection(TestCase):
2428

2529
def test_path_without_parameters(self):
@@ -61,6 +65,7 @@ def test_path_with_id_parameter(self):
6165
}
6266

6367

68+
@unittest.skipUnless(uritemplate, 'uritemplate is not installed')
6469
@override_settings(REST_FRAMEWORK={'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.inspectors.OpenAPIAutoSchema'})
6570
class TestGenerator(TestCase):
6671

0 commit comments

Comments
 (0)