mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-28 08:59:54 +03:00
add decimal format for number datatype
This commit is contained in:
parent
1362c57821
commit
cfd876ad1b
|
@ -337,10 +337,10 @@ class AutoSchema(ViewInspector):
|
||||||
elif all(isinstance(choice, int) for choice in choices):
|
elif all(isinstance(choice, int) for choice in choices):
|
||||||
mapping['type'] = 'integer'
|
mapping['type'] = 'integer'
|
||||||
elif all(isinstance(choice, Decimal) for choice in choices):
|
elif all(isinstance(choice, Decimal) for choice in choices):
|
||||||
|
mapping['format'] = 'decimal'
|
||||||
if api_settings.COERCE_DECIMAL_TO_STRING:
|
if api_settings.COERCE_DECIMAL_TO_STRING:
|
||||||
mapping['enum'] = [str(choice) for choice in mapping['enum']]
|
mapping['enum'] = [str(choice) for choice in mapping['enum']]
|
||||||
mapping['type'] = 'string'
|
mapping['type'] = 'string'
|
||||||
mapping['format'] = 'decimal'
|
|
||||||
else:
|
else:
|
||||||
mapping['type'] = 'number'
|
mapping['type'] = 'number'
|
||||||
elif all(isinstance(choice, (int, float, Decimal)) for choice in choices): # `number` includes `integer`
|
elif all(isinstance(choice, (int, float, Decimal)) for choice in choices): # `number` includes `integer`
|
||||||
|
|
Loading…
Reference in New Issue
Block a user