forked from loafle/openapi-generator-original
[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:
@@ -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 + "\"";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 + "\"";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 "Cat").</param>
|
||||
/// <param name="color">color (default to "red").</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;
|
||||
}
|
||||
|
||||
@@ -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 "Dog").</param>
|
||||
/// <param name="color">color (default to "red").</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;
|
||||
}
|
||||
|
||||
@@ -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 "Cat").</param>
|
||||
/// <param name="color">color (default to "red").</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;
|
||||
}
|
||||
|
||||
@@ -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 "Dog").</param>
|
||||
/// <param name="color">color (default to "red").</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;
|
||||
}
|
||||
|
||||
@@ -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 "ParentPet").</param>
|
||||
public ParentPet(string petType = "ParentPet") : base(petType)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user