Repository: baobabsoluciones/cornflow (language: python)

Issue:
Review changes in newer versions of marshmallow
**Is your feature request related to a problem? Please describe.**
Newer versions of `marshmallow `introduce new option for the validation of schemas that could be useful

**Describe the solution you'd like**
Review the changes introduced after version 3.6.0 and see if are useful for `cornflow `and the changes that need to be done in order to implement them.

**Describe alternatives you've considered**
Not updating yet the version.

**Additional context**
This comes from an error identified in issue #81 with conflicting versions between `apispec `and `marshmallow`.



Discussion / hints:

Fix patch:
diff --git a/cornflow/schemas/case.py b/cornflow/schemas/case.py
index ad289916..74a2a88b 100644
--- a/cornflow/schemas/case.py
+++ b/cornflow/schemas/case.py
@@ -18,7 +18,7 @@ class CaseRawRequest(Schema):
     schema = fields.Str(required=True)
     parent_id = fields.Int(allow_none=True)
     data = fields.Raw()
-    solution = fields.Raw(allow_none=True, default=None)
+    solution = fields.Raw(allow_none=True, dump_default=None)
 
 
 class CaseListResponse(BaseDataEndpointResponse):
@@ -85,5 +85,5 @@ class QueryFiltersCase(QueryFilters):
 
 
 class QueryCaseCompare(Schema):
-    data = fields.Boolean(required=False, default=1)
-    solution = fields.Boolean(required=False, default=1)
+    data = fields.Boolean(required=False, dump_default=1)
+    solution = fields.Boolean(required=False, dump_default=1)
diff --git a/cornflow/schemas/common.py b/cornflow/schemas/common.py
index dae524e2..dd49fa04 100644
--- a/cornflow/schemas/common.py
+++ b/cornflow/schemas/common.py
@@ -5,8 +5,8 @@
 
 
 class QueryFilters(Schema):
-    limit = fields.Int(required=False, default=20)
-    offset = fields.Int(required=False, default=0)
+    limit = fields.Int(required=False, dump_default=20)
+    offset = fields.Int(required=False, dump_default=0)
     creation_date_gte = fields.DateTime(required=False)
     creation_date_lte = fields.DateTime(required=False)
     schema = fields.Str(required=False)
diff --git a/cornflow/schemas/execution.py b/cornflow/schemas/execution.py
index c10abd58..2de7a6db 100644
--- a/cornflow/schemas/execution.py
+++ b/cornflow/schemas/execution.py
@@ -10,7 +10,9 @@ class QueryFiltersExecution(QueryFilters):
 
 
 class ConfigSchema(Schema):
-    solver = fields.Str(default="PULP_CBC_CMD", required=False)
+    solver = fields.Str(
+        dump_default="PULP_CBC_CMD", load_default="PULP_CBC_CMD", required=False
+    )
     mip = fields.Boolean(required=False)
     msg = fields.Boolean(required=False)
     warmStart = fields.Boolean(required=False)
diff --git a/requirements.txt b/requirements.txt
index 6c9e848d..5dfd3527 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,6 +1,6 @@
 alembic==1.4.2
 aniso8601==8.0.0
-apispec==4.4.2
+apispec
 bcrypt==3.1.7
 certifi==2020.6.20
 cffi==1.14.0
@@ -9,7 +9,7 @@ click==7.1.2
 cornflow-client @ git+https://github.com/baobabsoluciones/cornflow-client@master
 cryptography>=3.3.2
 Flask==1.1.2
-flask-apispec==0.11.0
+flask-apispec
 Flask-Bcrypt==0.7.1
 flask-compress==1.9.0
 flask-cors==3.0.10
@@ -28,7 +28,7 @@ jsonpatch==1.32
 ldap3==2.9
 Mako==1.1.2
 MarkupSafe==1.1.1
-marshmallow==3.6.0
+marshmallow
 psycopg2==2.8.5
 PuLP
 pyasn1==0.4.8


Test patch:
diff --git a/cornflow/tests/unit/test_schemas.py b/cornflow/tests/unit/test_schemas.py
index f279cf5a..a23ec9ae 100644
--- a/cornflow/tests/unit/test_schemas.py
+++ b/cornflow/tests/unit/test_schemas.py
@@ -13,20 +13,20 @@ class SchemaGenerator(unittest.TestCase):
     data1 = [
         {
             "name": "filename",
-            "description": "Should be a filename",
             "required": True,
             "type": "String",
             "valid_values": ["hello.txt", "foo.py", "bar.png"],
+            "metadata": {"description": "Should be a filename"},
         },
         {
             "name": "SomeBool",
-            "description": "Just a bool",
+            "metadata": {"description": "Just a bool"},
             "required": True,
             "type": "Boolean",
         },
         {
             "name": "NotRequiredBool",
-            "description": "Another bool that's not required",
+            "metadata": {"description": "Another bool that's not required"},
             "required": False,
             "type": "Boolean",
         },