Skip to content

Commit 8059470

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

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

rest_framework/schemas/generators.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616

1717
from rest_framework import exceptions
1818
from rest_framework.compat import (
19-
URLPattern, URLResolver, coreapi, coreschema, get_original_route
19+
URLPattern, URLResolver, coreapi, coreschema, get_original_route,
20+
uritemplate
2021
)
2122
from rest_framework.request import clone_request
2223
from rest_framework.settings import api_settings
@@ -484,6 +485,10 @@ def get_keys(self, subpath, method, view):
484485

485486
class OpenAPISchemaGenerator(BaseSchemaGenerator):
486487

488+
def __init__(self, title=None, url=None, description=None, patterns=None, urlconf=None):
489+
assert uritemplate, '`uritemplate` must be installed for OpenAPI schema support.'
490+
super(OpenAPISchemaGenerator, self).__init__(title, url, description, patterns, urlconf)
491+
487492
def get_paths(self, request=None):
488493
result = OrderedDict()
489494

tests/schemas/test_openapi.py

Lines changed: 4 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
@@ -39,6 +42,7 @@ def test_path_without_parameters(self):
3942
'parameters': []
4043
}
4144

45+
@unittest.skipUnless(uritemplate, 'uritemplate is not installed')
4246
def test_path_with_id_parameter(self):
4347
path = '/example/{id}/'
4448
method = 'GET'

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy