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,19 +935,19 @@ class CoreJSONRenderer(BaseRenderer):
|
||||||
|
|
||||||
|
|
||||||
class _BaseOpenAPIRenderer:
|
class _BaseOpenAPIRenderer:
|
||||||
CLASS_TO_TYPENAME = {
|
|
||||||
coreschema.Object: 'object',
|
|
||||||
coreschema.Array: 'array',
|
|
||||||
coreschema.Number: 'number',
|
|
||||||
coreschema.Integer: 'integer',
|
|
||||||
coreschema.String: 'string',
|
|
||||||
coreschema.Boolean: 'boolean',
|
|
||||||
}
|
|
||||||
|
|
||||||
def get_schema(self, instance):
|
def get_schema(self, instance):
|
||||||
|
CLASS_TO_TYPENAME = {
|
||||||
|
coreschema.Object: 'object',
|
||||||
|
coreschema.Array: 'array',
|
||||||
|
coreschema.Number: 'number',
|
||||||
|
coreschema.Integer: 'integer',
|
||||||
|
coreschema.String: 'string',
|
||||||
|
coreschema.Boolean: 'boolean',
|
||||||
|
}
|
||||||
|
|
||||||
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