Defer settings imports to avoid ImportErrors

openapi3
Cristi Vîjdea 2018-09-09 21:56:00 +03:00
parent e146a9712e
commit 6e39a58b2d
1 changed files with 6 additions and 4 deletions

View File

@ -48,9 +48,7 @@ def deferred_never_cache(view_func):
def get_schema_view(info=None, url=None, patterns=None, urlconf=None, public=False, validators=None, def get_schema_view(info=None, url=None, patterns=None, urlconf=None, public=False, validators=None,
generator_class=swagger_settings.DEFAULT_GENERATOR_CLASS, generator_class=None, authentication_classes=None, permission_classes=None):
authentication_classes=api_settings.DEFAULT_AUTHENTICATION_CLASSES,
permission_classes=api_settings.DEFAULT_PERMISSION_CLASSES):
"""Create a SchemaView class with default renderers and generators. """Create a SchemaView class with default renderers and generators.
:param .Info info: information about the API; if omitted, defaults to :ref:`DEFAULT_INFO <default-swagger-settings>` :param .Info info: information about the API; if omitted, defaults to :ref:`DEFAULT_INFO <default-swagger-settings>`
@ -66,9 +64,13 @@ def get_schema_view(info=None, url=None, patterns=None, urlconf=None, public=Fal
:rtype: type[.SchemaView] :rtype: type[.SchemaView]
""" """
_public = public _public = public
_generator_class = generator_class _generator_class = generator_class or swagger_settings.DEFAULT_GENERATOR_CLASS
_auth_classes = authentication_classes _auth_classes = authentication_classes
if _auth_classes is None:
_auth_classes = api_settings.DEFAULT_AUTHENTICATION_CLASSES
_perm_classes = permission_classes _perm_classes = permission_classes
if _perm_classes is None:
_perm_classes = api_settings.DEFAULT_PERMISSION_CLASSES
info = info or swagger_settings.DEFAULT_INFO info = info or swagger_settings.DEFAULT_INFO
validators = validators or [] validators = validators or []
_spec_renderers = tuple(renderer.with_validators(validators) for renderer in SPEC_RENDERERS) _spec_renderers = tuple(renderer.with_validators(validators) for renderer in SPEC_RENDERERS)