Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Aug 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ public CodegenModel fromModel(String name, Schema model) {
}

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 + "\"";
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ public CodegenModel fromModel(String name, Schema model) {
}

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 + "\"";
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ protected Cat() { }
/// 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ protected Dog() { }
/// 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ protected Cat() { }
/// 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ protected Dog() { }
/// 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ protected ParentPet() { }
/// <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)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected Cat() { }
/// 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected Dog() { }
/// 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;
}
Expand Down