Skip to content

Commit

Permalink
Add a method returns discriminator name
Browse files Browse the repository at this point in the history
  • Loading branch information
ackintosh committed Apr 1, 2018
1 parent 7daa2ec commit 28fcf48
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,11 @@ public void setUnescapedDescription(String unescapedDescription) {
this.unescapedDescription = unescapedDescription;
}

public String getDiscriminator() {
public Discriminator getDiscriminator() {
return discriminator;
}

public String getDiscriminatorName() {
return discriminator == null ? null : discriminator.getPropertyName();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}{{^parentSchema}}implements ModelInterface, ArrayAccess{{/parentSchema}}
{
const DISCRIMINATOR = {{#discriminator}}'{{discriminator}}'{{/discriminator}}{{^discriminator}}null{{/discriminator}};
const DISCRIMINATOR = {{#discriminator}}'{{discriminatorName}}'{{/discriminator}}{{^discriminator}}null{{/discriminator}};

/**
* The original name of the model.
Expand Down Expand Up @@ -166,7 +166,7 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}{{^pa
{{#discriminator}}

// Initialize discriminator property with the model name.
$discriminator = array_search('{{discriminator}}', self::$attributeMap);
$discriminator = array_search('{{discriminatorName}}', self::$attributeMap);
$this->container[$discriminator] = static::$swaggerModelName;
{{/discriminator}}
}
Expand Down

0 comments on commit 28fcf48

Please # to comment.