mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-31 18:40:07 +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_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):
|
||||
CLASS_TO_TYPENAME = {
|
||||
coreschema.Object: 'object',
|
||||
coreschema.Array: 'array',
|
||||
coreschema.Number: 'number',
|
||||
coreschema.Integer: 'integer',
|
||||
coreschema.String: 'string',
|
||||
coreschema.Boolean: 'boolean',
|
||||
}
|
||||
|
||||
schema = {}
|
||||
if instance.__class__ in self.CLASS_TO_TYPENAME:
|
||||
schema['type'] = self.CLASS_TO_TYPENAME[instance.__class__]
|
||||
if instance.__class__ in CLASS_TO_TYPENAME:
|
||||
schema['type'] = CLASS_TO_TYPENAME[instance.__class__]
|
||||
schema['title'] = instance.title,
|
||||
schema['description'] = instance.description
|
||||
if hasattr(instance, 'enum'):
|
||||
|
|
Loading…
Reference in New Issue
Block a user