mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-28 00:49:49 +03:00
[OpenAPI] Schemas Generator minor improvements, better generalization for third-party integrations
Added **kwargs in schema contructors and related callables that initialize it. The goal: have a better generalization for third-party schema generators that would need more arguments in BaseGenerator. __init__
This commit is contained in:
parent
559088463b
commit
88b4cdbb52
|
@ -32,7 +32,7 @@ def get_schema_view(
|
||||||
public=False, patterns=None, generator_class=None,
|
public=False, patterns=None, generator_class=None,
|
||||||
authentication_classes=api_settings.DEFAULT_AUTHENTICATION_CLASSES,
|
authentication_classes=api_settings.DEFAULT_AUTHENTICATION_CLASSES,
|
||||||
permission_classes=api_settings.DEFAULT_PERMISSION_CLASSES,
|
permission_classes=api_settings.DEFAULT_PERMISSION_CLASSES,
|
||||||
version=None):
|
version=None, **kwargs):
|
||||||
"""
|
"""
|
||||||
Return a schema view.
|
Return a schema view.
|
||||||
"""
|
"""
|
||||||
|
@ -44,7 +44,7 @@ def get_schema_view(
|
||||||
|
|
||||||
generator = generator_class(
|
generator = generator_class(
|
||||||
title=title, url=url, description=description,
|
title=title, url=url, description=description,
|
||||||
urlconf=urlconf, patterns=patterns, version=version
|
urlconf=urlconf, patterns=patterns, version=version, **kwargs
|
||||||
)
|
)
|
||||||
|
|
||||||
# Avoid import cycle on APIView
|
# Avoid import cycle on APIView
|
||||||
|
|
|
@ -151,7 +151,9 @@ class BaseSchemaGenerator:
|
||||||
# Set by 'SCHEMA_COERCE_PATH_PK'.
|
# Set by 'SCHEMA_COERCE_PATH_PK'.
|
||||||
coerce_path_pk = None
|
coerce_path_pk = None
|
||||||
|
|
||||||
def __init__(self, title=None, url=None, description=None, patterns=None, urlconf=None, version=None):
|
def __init__(self, title=None, url=None, description=None,
|
||||||
|
patterns=None, urlconf=None, version=None, **kwargs):
|
||||||
|
|
||||||
if url and not url.endswith('/'):
|
if url and not url.endswith('/'):
|
||||||
url += '/'
|
url += '/'
|
||||||
|
|
||||||
|
@ -165,6 +167,9 @@ class BaseSchemaGenerator:
|
||||||
self.url = url
|
self.url = url
|
||||||
self.endpoints = None
|
self.endpoints = None
|
||||||
|
|
||||||
|
for k, v in kwargs.items():
|
||||||
|
setattr(self, k, v)
|
||||||
|
|
||||||
def _initialise_endpoints(self):
|
def _initialise_endpoints(self):
|
||||||
if self.endpoints is None:
|
if self.endpoints is None:
|
||||||
inspector = self.endpoint_inspector_cls(self.patterns, self.urlconf)
|
inspector = self.endpoint_inspector_cls(self.patterns, self.urlconf)
|
||||||
|
|
|
@ -113,9 +113,8 @@ class SchemaGenerator(BaseSchemaGenerator):
|
||||||
|
|
||||||
return schema
|
return schema
|
||||||
|
|
||||||
|
|
||||||
# View Inspectors
|
# View Inspectors
|
||||||
|
|
||||||
|
|
||||||
class AutoSchema(ViewInspector):
|
class AutoSchema(ViewInspector):
|
||||||
|
|
||||||
def __init__(self, tags=None, operation_id_base=None, component_name=None):
|
def __init__(self, tags=None, operation_id_base=None, component_name=None):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user