From 9a3ffd91030a825f2f9bbeb0d58b8e59b1a60994 Mon Sep 17 00:00:00 2001 From: TVLIgnacy <51340748+TVLIgnacy@users.noreply.github.com> Date: Wed, 27 Jan 2021 13:27:09 +0000 Subject: [PATCH] Fix Float field handling of None values Resolves issue #240 by making sure a None value is not attempted to be converted to a float --- flask_restx/fields.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/flask_restx/fields.py b/flask_restx/fields.py index 031fdd61..ef357df6 100644 --- a/flask_restx/fields.py +++ b/flask_restx/fields.py @@ -481,6 +481,8 @@ class Float(NumberMixin, Raw): def format(self, value): try: + if value is None: + return self.default return float(value) except (ValueError, TypeError) as ve: raise MarshallingError(ve)