starmallow 0.5.1__py3-none-any.whl → 0.6.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- starmallow/__init__.py +1 -1
- starmallow/endpoint.py +2 -0
- starmallow/request_resolver.py +12 -8
- starmallow/schema_generator.py +5 -1
- {starmallow-0.5.1.dist-info → starmallow-0.6.1.dist-info}/METADATA +1 -1
- {starmallow-0.5.1.dist-info → starmallow-0.6.1.dist-info}/RECORD +8 -8
- {starmallow-0.5.1.dist-info → starmallow-0.6.1.dist-info}/WHEEL +0 -0
- {starmallow-0.5.1.dist-info → starmallow-0.6.1.dist-info}/licenses/LICENSE.md +0 -0
starmallow/__init__.py
CHANGED
starmallow/endpoint.py
CHANGED
starmallow/request_resolver.py
CHANGED
@@ -90,16 +90,20 @@ def request_params_to_args(
|
|
90
90
|
error_store.store_error(error.messages, field_name)
|
91
91
|
elif isinstance(param.model, ma.Schema):
|
92
92
|
try:
|
93
|
-
if ignore_namespace
|
94
|
-
|
95
|
-
|
93
|
+
load_params = received_params if ignore_namespace else received_params.get(alias, {})
|
94
|
+
|
95
|
+
# Entire model is optional and no data was passed in.
|
96
|
+
if getattr(param.model, 'required', None) is False and not load_params:
|
97
|
+
values[field_name] = None
|
96
98
|
else:
|
97
|
-
values[field_name] = param.model.load(
|
98
|
-
|
99
|
-
unknown=ma.EXCLUDE,
|
100
|
-
)
|
99
|
+
values[field_name] = param.model.load(load_params, unknown=ma.EXCLUDE)
|
100
|
+
|
101
101
|
except ma.ValidationError as error:
|
102
|
-
|
102
|
+
# Entire model is optional, so ignore errors
|
103
|
+
if getattr(param.model, 'required', None) is False:
|
104
|
+
values[field_name] = None
|
105
|
+
else:
|
106
|
+
error_store.store_error(error.messages)
|
103
107
|
else:
|
104
108
|
raise Exception(f'Invalid model type {type(param.model)}, expected marshmallow Schema or Field')
|
105
109
|
|
starmallow/schema_generator.py
CHANGED
@@ -223,6 +223,7 @@ class SchemaGenerator(BaseSchemaGenerator):
|
|
223
223
|
*endpoint.form_params.items(),
|
224
224
|
]
|
225
225
|
schema_by_media_type = {}
|
226
|
+
is_body_required = True
|
226
227
|
|
227
228
|
# If only 1 schema is defined. Use it as the entire schema.
|
228
229
|
if len(all_body_params) == 1 and isinstance(all_body_params[0][1].model, ma.Schema):
|
@@ -233,6 +234,9 @@ class SchemaGenerator(BaseSchemaGenerator):
|
|
233
234
|
if endpoint_schema:
|
234
235
|
schema_by_media_type[body_param.media_type] = {'schema': endpoint_schema}
|
235
236
|
|
237
|
+
if getattr(body_param.model, 'required', True) is False:
|
238
|
+
is_body_required = False
|
239
|
+
|
236
240
|
# Otherwise, loop over all body params and build a new schema from the key value pairs.
|
237
241
|
# This mimic's FastApi's behaviour: https://fastapi.tiangolo.com/tutorial/body-multiple-params/#multiple-body-parameters
|
238
242
|
else:
|
@@ -280,7 +284,7 @@ class SchemaGenerator(BaseSchemaGenerator):
|
|
280
284
|
if schema_by_media_type:
|
281
285
|
schema['requestBody'] = {
|
282
286
|
'content': schema_by_media_type,
|
283
|
-
'required':
|
287
|
+
'required': is_body_required,
|
284
288
|
}
|
285
289
|
|
286
290
|
def _add_security_params(
|
@@ -1,4 +1,4 @@
|
|
1
|
-
starmallow/__init__.py,sha256=
|
1
|
+
starmallow/__init__.py,sha256=DlB_5whNjhGyK9ZsUBi33R-sEwMl7EMsUsUJtXcI0F4,322
|
2
2
|
starmallow/applications.py,sha256=mSL4YDozP8n6v22g4NX7EAMXmGhzzhtjtZd68YHcFvw,31720
|
3
3
|
starmallow/concurrency.py,sha256=MVRjo4Vqss_yqhaoeVt3xb7rLaSuAq_q9uYgTwbsojE,1375
|
4
4
|
starmallow/constants.py,sha256=u0h8cJKhJY0oIZqzr7wpEZG2bPLrw5FroMnn3d8KBNQ,129
|
@@ -7,17 +7,17 @@ starmallow/datastructures.py,sha256=iH_KJuJ6kBCWEsnHFLdA3iyb6ZxhfdMHYrJlhiEZtDU,
|
|
7
7
|
starmallow/decorators.py,sha256=MYk3WEFRSfQTN0Y3JoL3Y_Cz47gatMrVEPtNDw42XwU,4105
|
8
8
|
starmallow/delimited_field.py,sha256=gonWgYg6G5xH2yXAyfDgkePmQ8dUaRSp2hdJ3mCfOBw,3466
|
9
9
|
starmallow/docs.py,sha256=eA39LunVMEoPU5ge4qxm2eiJbrFTUSUu5EhG1L_LKxk,6268
|
10
|
-
starmallow/endpoint.py,sha256=
|
10
|
+
starmallow/endpoint.py,sha256=WTXimVb6lfCYAUY8KDZS-mc1yHynSBjR2Sa4IGol2fc,15921
|
11
11
|
starmallow/endpoints.py,sha256=UrwVZCxbmWI20iNtJ0oXxo4d3-y12TjsOGs_jnStTiU,939
|
12
12
|
starmallow/exception_handlers.py,sha256=gr2qLYWEtsIEH28n7OreEiiLVz6Y7b6osRyS9esJbBk,891
|
13
13
|
starmallow/exceptions.py,sha256=vabtPJkTmtCdC8_2OPBE8Osz0v0KxaSOX6IWf1jgNkc,872
|
14
14
|
starmallow/fields.py,sha256=arrTabCYoJFZcoY69EZTBH3YUg7CUSr3-zYLiAjYLTM,1238
|
15
15
|
starmallow/params.py,sha256=MJzUzUs6GEyrbpDZ1r8To8vR-QwpopdxDStq802o5Ug,8662
|
16
|
-
starmallow/request_resolver.py,sha256=
|
16
|
+
starmallow/request_resolver.py,sha256=JoCxqdDYyniwNsI6FeeYKB7Muj9xDQ8LEA2ICba8n24,11012
|
17
17
|
starmallow/requests.py,sha256=o_yNhH9WJ35uAGuoXa5_gihevHeaveOvkP525dbwQSU,843
|
18
18
|
starmallow/responses.py,sha256=k2pf_m21ykf_FECdODUz400pMucMJJf_Zm8TXFujvaU,2012
|
19
19
|
starmallow/routing.py,sha256=Uxnlkl4eIs56TZ8VAgNmlh-K89ku1Xu_ROR5S8x-rkg,45128
|
20
|
-
starmallow/schema_generator.py,sha256=
|
20
|
+
starmallow/schema_generator.py,sha256=yi368FwF9B50ZHSNOG0rvYVirVUeMFq2kXkUDeJUz4w,17961
|
21
21
|
starmallow/serializers.py,sha256=rBEKMNgONgz_bai12uDvAEMCI_aEFGsqMSeIoWtlrOI,12514
|
22
22
|
starmallow/types.py,sha256=8GXWjvzXQhF5NMHf14fbid6uErxVd1Xk_w2I4FoUgZ4,717
|
23
23
|
starmallow/utils.py,sha256=Ab6F2yOiy65gVGC2C4mNyKiPTPdsRyH5eVAv7Q_dGbw,11436
|
@@ -34,7 +34,7 @@ starmallow/security/http.py,sha256=cpGjM1kFDq3i_bOY96kMkf4cspBUxFkkET9lTK3NA-0,6
|
|
34
34
|
starmallow/security/oauth2.py,sha256=1nv1580PY4cwgu5gzpQCf2MfMNv2Cfv05753AUHPOhQ,10005
|
35
35
|
starmallow/security/open_id_connect_url.py,sha256=IPsL2YzWc2mPwJbrUn6oFRTi7uRAG6mR62CGwmzBs1k,1399
|
36
36
|
starmallow/security/utils.py,sha256=bd8T0YM7UQD5ATKucr1bNtAvz_Y3__dVNAv5UebiPvc,293
|
37
|
-
starmallow-0.
|
38
|
-
starmallow-0.
|
39
|
-
starmallow-0.
|
40
|
-
starmallow-0.
|
37
|
+
starmallow-0.6.1.dist-info/METADATA,sha256=T_VIdPAgpTXGjVr4xDLPhpe-XW5tPlUa8su81s22lyw,5651
|
38
|
+
starmallow-0.6.1.dist-info/WHEEL,sha256=y1bSCq4r5i4nMmpXeUJMqs3ipKvkZObrIXSvJHm1qCI,87
|
39
|
+
starmallow-0.6.1.dist-info/licenses/LICENSE.md,sha256=QelyGgOzch8CXzy6HrYwHh7nmj0rlWkDA0YzmZ3CPaY,1084
|
40
|
+
starmallow-0.6.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|