starmallow 0.5.0__py3-none-any.whl → 0.6.0__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/params.py +1 -0
- starmallow/request_resolver.py +15 -9
- starmallow/schema_generator.py +5 -1
- starmallow/utils.py +2 -2
- {starmallow-0.5.0.dist-info → starmallow-0.6.0.dist-info}/METADATA +1 -1
- {starmallow-0.5.0.dist-info → starmallow-0.6.0.dist-info}/RECORD +10 -10
- {starmallow-0.5.0.dist-info → starmallow-0.6.0.dist-info}/WHEEL +0 -0
- {starmallow-0.5.0.dist-info → starmallow-0.6.0.dist-info}/licenses/LICENSE.md +0 -0
starmallow/__init__.py
CHANGED
starmallow/endpoint.py
CHANGED
starmallow/params.py
CHANGED
starmallow/request_resolver.py
CHANGED
@@ -90,16 +90,22 @@ 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
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
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') is False and not load_params:
|
97
|
+
# values[field_name] = None
|
98
|
+
# else:
|
99
|
+
# NOTE: If schema is not required, but there are some params defined then we will try to load
|
100
|
+
# This is because multiple schemas/fields may be defined per ParamType.
|
101
|
+
values[field_name] = param.model.load(load_params, unknown=ma.EXCLUDE)
|
102
|
+
|
101
103
|
except ma.ValidationError as error:
|
102
|
-
|
104
|
+
# Entire model is optional, so ignore errors
|
105
|
+
if getattr(param.model, 'required', None) is False:
|
106
|
+
values[field_name] = None
|
107
|
+
else:
|
108
|
+
error_store.store_error(error.messages)
|
103
109
|
else:
|
104
110
|
raise Exception(f'Invalid model type {type(param.model)}, expected marshmallow Schema or Field')
|
105
111
|
|
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(
|
starmallow/utils.py
CHANGED
@@ -9,7 +9,7 @@ from contextlib import AsyncExitStack, asynccontextmanager, contextmanager
|
|
9
9
|
from dataclasses import is_dataclass
|
10
10
|
from decimal import Decimal
|
11
11
|
from enum import Enum
|
12
|
-
from types import NoneType
|
12
|
+
from types import NoneType, UnionType
|
13
13
|
from typing import (
|
14
14
|
TYPE_CHECKING,
|
15
15
|
Any,
|
@@ -191,7 +191,7 @@ def is_body_allowed_for_status_code(status_code: int | str | None) -> bool:
|
|
191
191
|
|
192
192
|
|
193
193
|
def is_optional(field):
|
194
|
-
return get_origin(field)
|
194
|
+
return get_origin(field) in (Union, UnionType) and type(None) in get_args(field)
|
195
195
|
|
196
196
|
|
197
197
|
def get_path_param_names(path: str) -> Set[str]:
|
@@ -1,4 +1,4 @@
|
|
1
|
-
starmallow/__init__.py,sha256=
|
1
|
+
starmallow/__init__.py,sha256=HQAGoExawiWadHBvjDtczQGIc9vyqmGXuE4ddzl_lBs,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,20 +7,20 @@ 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
|
-
starmallow/params.py,sha256
|
16
|
-
starmallow/request_resolver.py,sha256=
|
15
|
+
starmallow/params.py,sha256=MJzUzUs6GEyrbpDZ1r8To8vR-QwpopdxDStq802o5Ug,8662
|
16
|
+
starmallow/request_resolver.py,sha256=5UpdK6NkT7jxTjw1XtSsyXgqfiQHmVBcMQdr0ycmego,11214
|
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
|
-
starmallow/utils.py,sha256=
|
23
|
+
starmallow/utils.py,sha256=Ab6F2yOiy65gVGC2C4mNyKiPTPdsRyH5eVAv7Q_dGbw,11436
|
24
24
|
starmallow/websockets.py,sha256=yIz3LzTBMNclpEoG7oTMbQwxbcdKNU6M8XcqZMyBTuA,2223
|
25
25
|
starmallow/ext/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
26
26
|
starmallow/ext/marshmallow/__init__.py,sha256=33jENGdfPq4-CDG0LOmN3KOGW1pXTy7a2oMwy4hrYzM,208
|
@@ -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.0.dist-info/METADATA,sha256=JLW2qKd2rbIU1kE7FHp2NoOeYDTckYEPR3tKGiRv-k0,5651
|
38
|
+
starmallow-0.6.0.dist-info/WHEEL,sha256=y1bSCq4r5i4nMmpXeUJMqs3ipKvkZObrIXSvJHm1qCI,87
|
39
|
+
starmallow-0.6.0.dist-info/licenses/LICENSE.md,sha256=QelyGgOzch8CXzy6HrYwHh7nmj0rlWkDA0YzmZ3CPaY,1084
|
40
|
+
starmallow-0.6.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|