mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-27 08:29:59 +03:00
Add a method for getting serializer field name
This commit is contained in:
parent
374c0d4142
commit
58f55b466a
|
@ -516,7 +516,7 @@ class AutoSchema(ViewInspector):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if field.required:
|
if field.required:
|
||||||
required.append(field.field_name)
|
required.append(self.get_field_name(field))
|
||||||
|
|
||||||
schema = self.map_field(field)
|
schema = self.map_field(field)
|
||||||
if field.read_only:
|
if field.read_only:
|
||||||
|
@ -531,7 +531,7 @@ class AutoSchema(ViewInspector):
|
||||||
schema['description'] = str(field.help_text)
|
schema['description'] = str(field.help_text)
|
||||||
self.map_field_validators(field, schema)
|
self.map_field_validators(field, schema)
|
||||||
|
|
||||||
properties[field.field_name] = schema
|
properties[self.get_field_name(field)] = schema
|
||||||
|
|
||||||
result = {
|
result = {
|
||||||
'type': 'object',
|
'type': 'object',
|
||||||
|
@ -582,6 +582,9 @@ class AutoSchema(ViewInspector):
|
||||||
schema['maximum'] = int(digits * '9') + 1
|
schema['maximum'] = int(digits * '9') + 1
|
||||||
schema['minimum'] = -schema['maximum']
|
schema['minimum'] = -schema['maximum']
|
||||||
|
|
||||||
|
def get_field_name(self, field):
|
||||||
|
return field.field_name
|
||||||
|
|
||||||
def get_paginator(self):
|
def get_paginator(self):
|
||||||
pagination_class = getattr(self.view, 'pagination_class', None)
|
pagination_class = getattr(self.view, 'pagination_class', None)
|
||||||
if pagination_class:
|
if pagination_class:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user