Skip to content

Commit 28c8095

Browse files
authored
Allow bool coercion/conversion (#922)
We were not handling that type properly for oneOf with booleans.
1 parent 483249c commit 28c8095

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

.generator/src/generator/templates/model_utils.j2

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -819,12 +819,14 @@ UPCONVERSION_TYPE_PAIRS = (
819819
(int, float), # A float may be serialized as an integer, e.g. '3' is a valid serialized float.
820820
(list, ModelComposed),
821821
(dict, ModelComposed),
822+
(bool, ModelComposed),
822823
(str, ModelComposed),
823824
(int, ModelComposed),
824825
(float, ModelComposed),
825826
(list, ModelComposed),
826827
(list, ModelNormal),
827828
(dict, ModelNormal),
829+
(bool, ModelSimple),
828830
(str, ModelSimple),
829831
(int, ModelSimple),
830832
(float, ModelSimple),
@@ -853,6 +855,7 @@ COERCIBLE_TYPE_PAIRS = {
853855
(list, ModelComposed),
854856
(dict, ModelNormal),
855857
(list, ModelNormal),
858+
(bool, ModelSimple),
856859
(str, ModelSimple),
857860
(int, ModelSimple),
858861
(float, ModelSimple),

src/datadog_api_client/model_utils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -821,12 +821,14 @@ def __eq__(self, other):
821821
(int, float), # A float may be serialized as an integer, e.g. '3' is a valid serialized float.
822822
(list, ModelComposed),
823823
(dict, ModelComposed),
824+
(bool, ModelComposed),
824825
(str, ModelComposed),
825826
(int, ModelComposed),
826827
(float, ModelComposed),
827828
(list, ModelComposed),
828829
(list, ModelNormal),
829830
(dict, ModelNormal),
831+
(bool, ModelSimple),
830832
(str, ModelSimple),
831833
(int, ModelSimple),
832834
(float, ModelSimple),
@@ -855,6 +857,7 @@ def __eq__(self, other):
855857
(list, ModelComposed),
856858
(dict, ModelNormal),
857859
(list, ModelNormal),
860+
(bool, ModelSimple),
858861
(str, ModelSimple),
859862
(int, ModelSimple),
860863
(float, ModelSimple),

0 commit comments

Comments
 (0)