[c-sharp] Fix default values with discriminator (#7296)

* [c-sharp] Fix #6225 default values with discriminator

* [c-sharp] Fix #6225 default values with discriminator

* update samples

Co-authored-by: Tom E <1036527+thommy101@users.noreply.github.com>
This commit is contained in:
William Cheng
2020-08-26 09:36:11 +08:00
committed by GitHub
parent bc4994e82c
commit e6d3201623
9 changed files with 14 additions and 14 deletions

View File

@@ -604,7 +604,7 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
}
for (final CodegenProperty property : codegenModel.readWriteVars) {
if (property.defaultValue == null && parentCodegenModel.discriminator != null && property.baseName.equals(parentCodegenModel.discriminator.getPropertyName())) {
if (property.defaultValue == null && parentCodegenModel.discriminator != null && property.name.equals(parentCodegenModel.discriminator.getPropertyName())) {
property.defaultValue = "\"" + name + "\"";
}
}

View File

@@ -299,7 +299,7 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
}
for (final CodegenProperty property : codegenModel.readWriteVars) {
if (property.defaultValue == null && parentCodegenModel.discriminator != null && property.baseName.equals(parentCodegenModel.discriminator.getPropertyName())) {
if (property.defaultValue == null && parentCodegenModel.discriminator != null && property.name.equals(parentCodegenModel.discriminator.getPropertyName())) {
property.defaultValue = "\"" + name + "\"";
}
}

View File

@@ -40,9 +40,9 @@ namespace Org.OpenAPITools.Model
/// Initializes a new instance of the <see cref="Cat" /> class.
/// </summary>
/// <param name="declawed">declawed.</param>
/// <param name="className">className (required).</param>
/// <param name="className">className (required) (default to &quot;Cat&quot;).</param>
/// <param name="color">color (default to &quot;red&quot;).</param>
public Cat(bool declawed = default(bool), string className = default(string), string color = "red") : base(className, color)
public Cat(bool declawed = default(bool), string className = "Cat", string color = "red") : base(className, color)
{
this.Declawed = declawed;
}

View File

@@ -40,9 +40,9 @@ namespace Org.OpenAPITools.Model
/// Initializes a new instance of the <see cref="Dog" /> class.
/// </summary>
/// <param name="breed">breed.</param>
/// <param name="className">className (required).</param>
/// <param name="className">className (required) (default to &quot;Dog&quot;).</param>
/// <param name="color">color (default to &quot;red&quot;).</param>
public Dog(string breed = default(string), string className = default(string), string color = "red") : base(className, color)
public Dog(string breed = default(string), string className = "Dog", string color = "red") : base(className, color)
{
this.Breed = breed;
}

View File

@@ -40,9 +40,9 @@ namespace Org.OpenAPITools.Model
/// Initializes a new instance of the <see cref="Cat" /> class.
/// </summary>
/// <param name="declawed">declawed.</param>
/// <param name="className">className (required).</param>
/// <param name="className">className (required) (default to &quot;Cat&quot;).</param>
/// <param name="color">color (default to &quot;red&quot;).</param>
public Cat(bool declawed = default(bool), string className = default(string), string color = "red") : base(className, color)
public Cat(bool declawed = default(bool), string className = "Cat", string color = "red") : base(className, color)
{
this.Declawed = declawed;
}

View File

@@ -40,9 +40,9 @@ namespace Org.OpenAPITools.Model
/// Initializes a new instance of the <see cref="Dog" /> class.
/// </summary>
/// <param name="breed">breed.</param>
/// <param name="className">className (required).</param>
/// <param name="className">className (required) (default to &quot;Dog&quot;).</param>
/// <param name="color">color (default to &quot;red&quot;).</param>
public Dog(string breed = default(string), string className = default(string), string color = "red") : base(className, color)
public Dog(string breed = default(string), string className = "Dog", string color = "red") : base(className, color)
{
this.Breed = breed;
}

View File

@@ -39,8 +39,8 @@ namespace Org.OpenAPITools.Model
/// <summary>
/// Initializes a new instance of the <see cref="ParentPet" /> class.
/// </summary>
/// <param name="petType">petType (required).</param>
public ParentPet(string petType = default(string)) : base(petType)
/// <param name="petType">petType (required) (default to &quot;ParentPet&quot;).</param>
public ParentPet(string petType = "ParentPet") : base(petType)
{
}

View File

@@ -39,7 +39,7 @@ namespace Org.OpenAPITools.Model
/// Initializes a new instance of the <see cref="Cat" /> class.
/// </summary>
/// <param name="declawed">declawed.</param>
public Cat(bool declawed = default(bool), string className = default(string), string color = "red") : base(className, color)
public Cat(bool declawed = default(bool), string className = "Cat", string color = "red") : base(className, color)
{
this.Declawed = declawed;
}

View File

@@ -39,7 +39,7 @@ namespace Org.OpenAPITools.Model
/// Initializes a new instance of the <see cref="Dog" /> class.
/// </summary>
/// <param name="breed">breed.</param>
public Dog(string breed = default(string), string className = default(string), string color = "red") : base(className, color)
public Dog(string breed = default(string), string className = "Dog", string color = "red") : base(className, color)
{
this.Breed = breed;
}