From 7daa2ec5dace6fdfc10b632f408770fca303ab0a Mon Sep 17 00:00:00 2001 From: "akihito.nakano" Date: Sun, 1 Apr 2018 18:29:13 +0900 Subject: [PATCH] Fix broken discriminator --- .../src/main/java/org/openapitools/codegen/CodegenModel.java | 4 ++-- .../petstore/php/SwaggerClient-php/lib/Model/Animal.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenModel.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenModel.java index 50c3248f5c18..2fd190b5e0e2 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenModel.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenModel.java @@ -331,8 +331,8 @@ public void setUnescapedDescription(String unescapedDescription) { this.unescapedDescription = unescapedDescription; } - public Discriminator getDiscriminator() { - return discriminator; + public String getDiscriminator() { + return discriminator == null ? null : discriminator.getPropertyName(); } public void setDiscriminator(Discriminator discriminator) { diff --git a/samples/openapi3/client/petstore/php/SwaggerClient-php/lib/Model/Animal.php b/samples/openapi3/client/petstore/php/SwaggerClient-php/lib/Model/Animal.php index 76a22ff9280e..aa5f32d9580f 100644 --- a/samples/openapi3/client/petstore/php/SwaggerClient-php/lib/Model/Animal.php +++ b/samples/openapi3/client/petstore/php/SwaggerClient-php/lib/Model/Animal.php @@ -42,7 +42,7 @@ */ class Animal implements ModelInterface, ArrayAccess { - const DISCRIMINATOR = 'Discriminator{propertyName='className', mapping=null}'; + const DISCRIMINATOR = 'className'; /** * The original name of the model. @@ -186,7 +186,7 @@ public function __construct(array $data = null) $this->container['color'] = isset($data['color']) ? $data['color'] : 'red'; // Initialize discriminator property with the model name. - $discriminator = array_search('Discriminator{propertyName='className', mapping=null}', self::$attributeMap); + $discriminator = array_search('className', self::$attributeMap); $this->container[$discriminator] = static::$swaggerModelName; }