From 41e97e6d2bd817c39e0ce6593acea8b9b290ddd6 Mon Sep 17 00:00:00 2001 From: "Sebastien Rosset (serosset)" Date: Tue, 12 May 2020 18:57:25 -0700 Subject: [PATCH 1/3] Mustache template should use invokerPackage tag to generate import --- .../Java/libraries/jersey2/AbstractOpenApiSchema.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/AbstractOpenApiSchema.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/AbstractOpenApiSchema.mustache index cdba3be84552..c924650e6c0a 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/AbstractOpenApiSchema.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/AbstractOpenApiSchema.mustache @@ -2,7 +2,7 @@ package {{invokerPackage}}.model; -import org.openapitools.client.ApiException; +import {{invokerPackage}}.ApiException; import java.lang.reflect.Type; import java.util.Map; import javax.ws.rs.core.GenericType; From 6d1dc6fbbcb42fc07ce5f978232d7e7efeac8adf Mon Sep 17 00:00:00 2001 From: "Sebastien Rosset (serosset)" Date: Thu, 21 May 2020 13:06:27 -0700 Subject: [PATCH 2/3] Fix runtime exception when composed schema has 'null' type --- .../resources/python/python-experimental/model_utils.mustache | 2 +- .../petstore/python-experimental/petstore_api/model_utils.py | 2 +- .../petstore/python-experimental/petstore_api/model_utils.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/python/python-experimental/model_utils.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/model_utils.mustache index 1c163a915a23..6275c35cb79a 100644 --- a/modules/openapi-generator/src/main/resources/python/python-experimental/model_utils.mustache +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/model_utils.mustache @@ -776,7 +776,7 @@ def get_discriminator_class(model_class, model_class._composed_schemas.get('allOf', ()) for cls in composed_children: # Check if the schema has inherited discriminators. - if cls.discriminator is not None: + if cls is not None and cls.discriminator is not None: used_model_class = get_discriminator_class( cls, discr_name, discr_value, cls_visited) if used_model_class is not None: diff --git a/samples/client/petstore/python-experimental/petstore_api/model_utils.py b/samples/client/petstore/python-experimental/petstore_api/model_utils.py index baf22c61d192..729a559ed2de 100644 --- a/samples/client/petstore/python-experimental/petstore_api/model_utils.py +++ b/samples/client/petstore/python-experimental/petstore_api/model_utils.py @@ -1043,7 +1043,7 @@ def get_discriminator_class(model_class, model_class._composed_schemas.get('allOf', ()) for cls in composed_children: # Check if the schema has inherited discriminators. - if cls.discriminator is not None: + if cls is not None and cls.discriminator is not None: used_model_class = get_discriminator_class( cls, discr_name, discr_value, cls_visited) if used_model_class is not None: diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model_utils.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model_utils.py index baf22c61d192..729a559ed2de 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model_utils.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model_utils.py @@ -1043,7 +1043,7 @@ def get_discriminator_class(model_class, model_class._composed_schemas.get('allOf', ()) for cls in composed_children: # Check if the schema has inherited discriminators. - if cls.discriminator is not None: + if cls is not None and cls.discriminator is not None: used_model_class = get_discriminator_class( cls, discr_name, discr_value, cls_visited) if used_model_class is not None: From e5bc80da6f62943c43370202a1743584eea4ff87 Mon Sep 17 00:00:00 2001 From: "Sebastien Rosset (serosset)" Date: Thu, 21 May 2020 13:12:43 -0700 Subject: [PATCH 3/3] Fix runtime exception when composed schema has 'null' type --- .../resources/python/python-experimental/model_utils.mustache | 2 +- .../petstore/python-experimental/petstore_api/model_utils.py | 2 +- .../petstore/python-experimental/petstore_api/model_utils.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/python/python-experimental/model_utils.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/model_utils.mustache index 6275c35cb79a..46c56f5c6756 100644 --- a/modules/openapi-generator/src/main/resources/python/python-experimental/model_utils.mustache +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/model_utils.mustache @@ -776,7 +776,7 @@ def get_discriminator_class(model_class, model_class._composed_schemas.get('allOf', ()) for cls in composed_children: # Check if the schema has inherited discriminators. - if cls is not None and cls.discriminator is not None: + if hasattr(cls, 'discriminator') and cls.discriminator is not None: used_model_class = get_discriminator_class( cls, discr_name, discr_value, cls_visited) if used_model_class is not None: diff --git a/samples/client/petstore/python-experimental/petstore_api/model_utils.py b/samples/client/petstore/python-experimental/petstore_api/model_utils.py index 729a559ed2de..82db1a86b662 100644 --- a/samples/client/petstore/python-experimental/petstore_api/model_utils.py +++ b/samples/client/petstore/python-experimental/petstore_api/model_utils.py @@ -1043,7 +1043,7 @@ def get_discriminator_class(model_class, model_class._composed_schemas.get('allOf', ()) for cls in composed_children: # Check if the schema has inherited discriminators. - if cls is not None and cls.discriminator is not None: + if hasattr(cls, 'discriminator') and cls.discriminator is not None: used_model_class = get_discriminator_class( cls, discr_name, discr_value, cls_visited) if used_model_class is not None: diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model_utils.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model_utils.py index 729a559ed2de..82db1a86b662 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model_utils.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model_utils.py @@ -1043,7 +1043,7 @@ def get_discriminator_class(model_class, model_class._composed_schemas.get('allOf', ()) for cls in composed_children: # Check if the schema has inherited discriminators. - if cls is not None and cls.discriminator is not None: + if hasattr(cls, 'discriminator') and cls.discriminator is not None: used_model_class = get_discriminator_class( cls, discr_name, discr_value, cls_visited) if used_model_class is not None: