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; }