Note dependency on uritemplate.

This commit is contained in:
Carlton Gibson 2018-08-09 15:43:26 +02:00
parent 4c173193d6
commit 416ca3fcca
2 changed files with 7 additions and 0 deletions

View File

@ -511,6 +511,8 @@ class OpenAPIAutoSchema(ViewInspector):
"""
Return a list of parameters from templated path variables.
"""
assert uritemplate, '`uritemplate` must be installed for OpenAPI schema support.'
model = getattr(getattr(self.view, 'queryset', None), 'model', None)
parameters = []

View File

@ -1,6 +1,9 @@
import unittest
from django.conf.urls import url
from django.test import RequestFactory, TestCase, override_settings
from rest_framework.compat import uritemplate
from rest_framework.request import Request
from rest_framework.schemas.generators import OpenAPISchemaGenerator
from rest_framework.schemas.inspectors import OpenAPIAutoSchema
@ -20,6 +23,7 @@ def create_view(view_cls, method, request):
return view
@unittest.skipUnless(uritemplate, 'uritemplate is not installed')
class TestOperationIntrospection(TestCase):
def test_path_without_parameters(self):
@ -61,6 +65,7 @@ class TestOperationIntrospection(TestCase):
}
@unittest.skipUnless(uritemplate, 'uritemplate is not installed')
@override_settings(REST_FRAMEWORK={'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.inspectors.OpenAPIAutoSchema'})
class TestGenerator(TestCase):