mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-02 11:30:12 +03:00
Pull coreschema references into method, so they are only used if 'OpenAPIRenderer' is in use.
This commit is contained in:
parent
9873fb87a7
commit
90fb5ae2fd
|
@ -935,6 +935,7 @@ class CoreJSONRenderer(BaseRenderer):
|
||||||
|
|
||||||
|
|
||||||
class _BaseOpenAPIRenderer:
|
class _BaseOpenAPIRenderer:
|
||||||
|
def get_schema(self, instance):
|
||||||
CLASS_TO_TYPENAME = {
|
CLASS_TO_TYPENAME = {
|
||||||
coreschema.Object: 'object',
|
coreschema.Object: 'object',
|
||||||
coreschema.Array: 'array',
|
coreschema.Array: 'array',
|
||||||
|
@ -944,10 +945,9 @@ class _BaseOpenAPIRenderer:
|
||||||
coreschema.Boolean: 'boolean',
|
coreschema.Boolean: 'boolean',
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_schema(self, instance):
|
|
||||||
schema = {}
|
schema = {}
|
||||||
if instance.__class__ in self.CLASS_TO_TYPENAME:
|
if instance.__class__ in CLASS_TO_TYPENAME:
|
||||||
schema['type'] = self.CLASS_TO_TYPENAME[instance.__class__]
|
schema['type'] = CLASS_TO_TYPENAME[instance.__class__]
|
||||||
schema['title'] = instance.title,
|
schema['title'] = instance.title,
|
||||||
schema['description'] = instance.description
|
schema['description'] = instance.description
|
||||||
if hasattr(instance, 'enum'):
|
if hasattr(instance, 'enum'):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user