Skip to content

Commit 583aa24

Browse files
[Python-experimental] Fix type error if oneof/anyof child schema is null type (#6387)
* Mustache template should use invokerPackage tag to generate import * Fix runtime exception when composed schema has 'null' type * Fix runtime exception when composed schema has 'null' type
1 parent afb3188 commit 583aa24

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

modules/openapi-generator/src/main/resources/python/python-experimental/model_utils.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ def get_discriminator_class(model_class,
779779
model_class._composed_schemas.get('allOf', ())
780780
for cls in composed_children:
781781
# Check if the schema has inherited discriminators.
782-
if cls.discriminator is not None:
782+
if hasattr(cls, 'discriminator') and cls.discriminator is not None:
783783
used_model_class = get_discriminator_class(
784784
cls, discr_name, discr_value, cls_visited)
785785
if used_model_class is not None:

samples/client/petstore/python-experimental/petstore_api/model_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1046,7 +1046,7 @@ def get_discriminator_class(model_class,
10461046
model_class._composed_schemas.get('allOf', ())
10471047
for cls in composed_children:
10481048
# Check if the schema has inherited discriminators.
1049-
if cls.discriminator is not None:
1049+
if hasattr(cls, 'discriminator') and cls.discriminator is not None:
10501050
used_model_class = get_discriminator_class(
10511051
cls, discr_name, discr_value, cls_visited)
10521052
if used_model_class is not None:

samples/openapi3/client/petstore/python-experimental/petstore_api/model_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1046,7 +1046,7 @@ def get_discriminator_class(model_class,
10461046
model_class._composed_schemas.get('allOf', ())
10471047
for cls in composed_children:
10481048
# Check if the schema has inherited discriminators.
1049-
if cls.discriminator is not None:
1049+
if hasattr(cls, 'discriminator') and cls.discriminator is not None:
10501050
used_model_class = get_discriminator_class(
10511051
cls, discr_name, discr_value, cls_visited)
10521052
if used_model_class is not None:

0 commit comments

Comments
 (0)