Skip to content

Commit c23e0cb

Browse files
committed
feat: improve resolving oneOf relationships
There was an issue resolving oneOf. A workaround was introduced some time ago, but it did not work for ExportDefinitionRequest. ExportDefinitionRequest was correctly matched, but it did not pass the assert, so it failed with the error that none oneOf could be used. Therefore, assert was extended for the use case when all model_kwargs are presented in oneof_class.openapi_types. This new condition and the old one should cover both cases. JIRA: PSDK-209 risk: low
1 parent d8198f9 commit c23e0cb

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

.openapi-generator/custom_templates/model_utils.mustache

+1-1
Original file line numberDiff line numberDiff line change
@@ -1547,7 +1547,7 @@ def get_oneof_instance(cls, model_kwargs, constant_kwargs, model_arg=None):
15471547
# Workaround for missing OneOf schema support by the generator
15481548
# Checks if the defined schema is a subset of received model
15491549
# This way we can ensure forward-compatibility support of new fields in API
1550-
assert set(oneof_class.openapi_types.keys()) <= set(model_kwargs.keys())
1550+
assert len(set(model_kwargs.keys()).difference(set(oneof_class.openapi_types.keys()))) == 0 or set(oneof_class.openapi_types.keys()) <= set(model_kwargs.keys())
15511551

15521552
else:
15531553
if issubclass(oneof_class, ModelSimple):

gooddata-api-client/gooddata_api_client/model_utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1877,7 +1877,7 @@ def get_oneof_instance(cls, model_kwargs, constant_kwargs, model_arg=None):
18771877
# Workaround for missing OneOf schema support by the generator
18781878
# Checks if the defined schema is a subset of received model
18791879
# This way we can ensure forward-compatibility support of new fields in API
1880-
assert set(oneof_class.openapi_types.keys()) <= set(model_kwargs.keys())
1880+
assert len(set(model_kwargs.keys()).difference(set(oneof_class.openapi_types.keys()))) == 0 or set(oneof_class.openapi_types.keys()) <= set(model_kwargs.keys())
18811881

18821882
else:
18831883
if issubclass(oneof_class, ModelSimple):

0 commit comments

Comments
 (0)