From cfd876ad1b2b496f066cfc55d6fe466fc771ea38 Mon Sep 17 00:00:00 2001 From: Dhaval Mehta <20968146+dhaval-mehta@users.noreply.github.com> Date: Wed, 8 Apr 2020 20:31:42 +0530 Subject: [PATCH] add decimal format for number datatype --- rest_framework/schemas/openapi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest_framework/schemas/openapi.py b/rest_framework/schemas/openapi.py index 5eaba6bfe..31627f58e 100644 --- a/rest_framework/schemas/openapi.py +++ b/rest_framework/schemas/openapi.py @@ -337,10 +337,10 @@ class AutoSchema(ViewInspector): elif all(isinstance(choice, int) for choice in choices): mapping['type'] = 'integer' elif all(isinstance(choice, Decimal) for choice in choices): + mapping['format'] = 'decimal' if api_settings.COERCE_DECIMAL_TO_STRING: mapping['enum'] = [str(choice) for choice in mapping['enum']] mapping['type'] = 'string' - mapping['format'] = 'decimal' else: mapping['type'] = 'number' elif all(isinstance(choice, (int, float, Decimal)) for choice in choices): # `number` includes `integer`