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#] fix integer enum without format #9136

Merged
merged 5 commits into from
Mar 31, 2021
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
2 changes: 1 addition & 1 deletion bin/utils/test_file_list.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
# csharp-netcore test files and image for upload
- filename: "samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools.Test/JSONComposedSchemaTests.cs"
sha256: ec34838fbbb1abb9f762949d510503b6237b607400a85c848c234c39d013a776
sha256: 95e40cace36e7cd1608fa494161f06291f4cfb8f859ec4196ae9939f520b152a
- filename: "samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools.Test/Api/PetApiTests.cs"
sha256: dae985015ba461297927d544a78267f2def35e07c3f14ca66468fd61e1fd1c26
- filename: "samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools.Test/linux-logo.png"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ public void updateCodegenPropertyEnum(CodegenProperty var) {
var.isString = false;
var.isLong = false;
var.isInteger = false;
} else if ("int32".equals(var.dataFormat)) {
} else if ("int".equals(var.dataType) || "int32".equals(var.dataFormat)) {
var.isInteger = true;
var.isString = false;
var.isLong = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
{{/complexType}}
{{/isEnum}}
{{#isEnum}}

/// <summary>
/// {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{description}}{{/description}}
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1546,6 +1546,11 @@ components:
enum:
- 1
- -1
enum_integer_only:
type: integer
enum:
- 2
- -2
enum_number:
type: number
format: double
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Name | Type | Description | Notes
**EnumString** | **string** | | [optional]
**EnumStringRequired** | **string** | |
**EnumInteger** | **int** | | [optional]
**EnumIntegerOnly** | **int** | | [optional]
**EnumNumber** | **double** | | [optional]
**OuterEnum** | **OuterEnum** | | [optional]
**OuterEnumInteger** | **OuterEnumInteger** | | [optional]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public enum PetTypeEnum

}


/// <summary>
/// Gets or Sets PetType
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public enum PetTypeEnum

}


/// <summary>
/// Gets or Sets PetType
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public enum JustSymbolEnum

}


/// <summary>
/// Gets or Sets JustSymbol
/// </summary>
Expand All @@ -78,6 +79,7 @@ public enum ArrayEnumEnum
}



/// <summary>
/// Gets or Sets ArrayEnum
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public enum EnumStringEnum

}


/// <summary>
/// Gets or Sets EnumString
/// </summary>
Expand Down Expand Up @@ -89,6 +90,7 @@ public enum EnumStringRequiredEnum

}


/// <summary>
/// Gets or Sets EnumStringRequired
/// </summary>
Expand All @@ -111,12 +113,36 @@ public enum EnumIntegerEnum

}


/// <summary>
/// Gets or Sets EnumInteger
/// </summary>
[DataMember(Name = "enum_integer", EmitDefaultValue = false)]
public EnumIntegerEnum? EnumInteger { get; set; }
/// <summary>
/// Defines EnumIntegerOnly
/// </summary>
public enum EnumIntegerOnlyEnum
{
/// <summary>
/// Enum NUMBER_2 for value: 2
/// </summary>
NUMBER_2 = 2,

/// <summary>
/// Enum NUMBER_MINUS_2 for value: -2
/// </summary>
NUMBER_MINUS_2 = -2

}


/// <summary>
/// Gets or Sets EnumIntegerOnly
/// </summary>
[DataMember(Name = "enum_integer_only", EmitDefaultValue = false)]
public EnumIntegerOnlyEnum? EnumIntegerOnly { get; set; }
/// <summary>
/// Defines EnumNumber
/// </summary>
[JsonConverter(typeof(StringEnumConverter))]
Expand All @@ -136,26 +162,31 @@ public enum EnumNumberEnum

}


/// <summary>
/// Gets or Sets EnumNumber
/// </summary>
[DataMember(Name = "enum_number", EmitDefaultValue = false)]
public EnumNumberEnum? EnumNumber { get; set; }

/// <summary>
/// Gets or Sets OuterEnum
/// </summary>
[DataMember(Name = "outerEnum", EmitDefaultValue = true)]
public OuterEnum? OuterEnum { get; set; }

/// <summary>
/// Gets or Sets OuterEnumInteger
/// </summary>
[DataMember(Name = "outerEnumInteger", EmitDefaultValue = false)]
public OuterEnumInteger? OuterEnumInteger { get; set; }

/// <summary>
/// Gets or Sets OuterEnumDefaultValue
/// </summary>
[DataMember(Name = "outerEnumDefaultValue", EmitDefaultValue = false)]
public OuterEnumDefaultValue? OuterEnumDefaultValue { get; set; }

/// <summary>
/// Gets or Sets OuterEnumIntegerDefaultValue
/// </summary>
Expand All @@ -175,16 +206,18 @@ protected EnumTest()
/// <param name="enumString">enumString.</param>
/// <param name="enumStringRequired">enumStringRequired (required).</param>
/// <param name="enumInteger">enumInteger.</param>
/// <param name="enumIntegerOnly">enumIntegerOnly.</param>
/// <param name="enumNumber">enumNumber.</param>
/// <param name="outerEnum">outerEnum.</param>
/// <param name="outerEnumInteger">outerEnumInteger.</param>
/// <param name="outerEnumDefaultValue">outerEnumDefaultValue.</param>
/// <param name="outerEnumIntegerDefaultValue">outerEnumIntegerDefaultValue.</param>
public EnumTest(EnumStringEnum? enumString = default(EnumStringEnum?), EnumStringRequiredEnum enumStringRequired = default(EnumStringRequiredEnum), EnumIntegerEnum? enumInteger = default(EnumIntegerEnum?), EnumNumberEnum? enumNumber = default(EnumNumberEnum?), OuterEnum? outerEnum = default(OuterEnum?), OuterEnumInteger? outerEnumInteger = default(OuterEnumInteger?), OuterEnumDefaultValue? outerEnumDefaultValue = default(OuterEnumDefaultValue?), OuterEnumIntegerDefaultValue? outerEnumIntegerDefaultValue = default(OuterEnumIntegerDefaultValue?))
public EnumTest(EnumStringEnum? enumString = default(EnumStringEnum?), EnumStringRequiredEnum enumStringRequired = default(EnumStringRequiredEnum), EnumIntegerEnum? enumInteger = default(EnumIntegerEnum?), EnumIntegerOnlyEnum? enumIntegerOnly = default(EnumIntegerOnlyEnum?), EnumNumberEnum? enumNumber = default(EnumNumberEnum?), OuterEnum? outerEnum = default(OuterEnum?), OuterEnumInteger? outerEnumInteger = default(OuterEnumInteger?), OuterEnumDefaultValue? outerEnumDefaultValue = default(OuterEnumDefaultValue?), OuterEnumIntegerDefaultValue? outerEnumIntegerDefaultValue = default(OuterEnumIntegerDefaultValue?))
{
this.EnumStringRequired = enumStringRequired;
this.EnumString = enumString;
this.EnumInteger = enumInteger;
this.EnumIntegerOnly = enumIntegerOnly;
this.EnumNumber = enumNumber;
this.OuterEnum = outerEnum;
this.OuterEnumInteger = outerEnumInteger;
Expand All @@ -210,6 +243,7 @@ public override string ToString()
sb.Append(" EnumString: ").Append(EnumString).Append("\n");
sb.Append(" EnumStringRequired: ").Append(EnumStringRequired).Append("\n");
sb.Append(" EnumInteger: ").Append(EnumInteger).Append("\n");
sb.Append(" EnumIntegerOnly: ").Append(EnumIntegerOnly).Append("\n");
sb.Append(" EnumNumber: ").Append(EnumNumber).Append("\n");
sb.Append(" OuterEnum: ").Append(OuterEnum).Append("\n");
sb.Append(" OuterEnumInteger: ").Append(OuterEnumInteger).Append("\n");
Expand Down Expand Up @@ -261,6 +295,7 @@ public override int GetHashCode()
hashCode = hashCode * 59 + this.EnumString.GetHashCode();
hashCode = hashCode * 59 + this.EnumStringRequired.GetHashCode();
hashCode = hashCode * 59 + this.EnumInteger.GetHashCode();
hashCode = hashCode * 59 + this.EnumIntegerOnly.GetHashCode();
hashCode = hashCode * 59 + this.EnumNumber.GetHashCode();
hashCode = hashCode * 59 + this.OuterEnum.GetHashCode();
hashCode = hashCode * 59 + this.OuterEnumInteger.GetHashCode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public enum InnerEnum
}



/// <summary>
/// Gets or Sets MapOfEnumString
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public enum StatusEnum

}


/// <summary>
/// Order Status
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public enum StatusEnum

}


/// <summary>
/// pet status in the store
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public enum TypeEnum

}


/// <summary>
/// Gets or Sets Type
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Name | Type | Description | Notes
**EnumString** | **string** | | [optional]
**EnumStringRequired** | **string** | |
**EnumInteger** | **int** | | [optional]
**EnumIntegerOnly** | **int** | | [optional]
**EnumNumber** | **double** | | [optional]
**OuterEnum** | **OuterEnum** | | [optional]
**OuterEnumInteger** | **OuterEnumInteger** | | [optional]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public enum PetTypeEnum

}


/// <summary>
/// Gets or Sets PetType
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public enum PetTypeEnum

}


/// <summary>
/// Gets or Sets PetType
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public enum JustSymbolEnum

}


/// <summary>
/// Gets or Sets JustSymbol
/// </summary>
Expand All @@ -78,6 +79,7 @@ public enum ArrayEnumEnum
}



/// <summary>
/// Gets or Sets ArrayEnum
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public enum EnumStringEnum

}


/// <summary>
/// Gets or Sets EnumString
/// </summary>
Expand Down Expand Up @@ -89,6 +90,7 @@ public enum EnumStringRequiredEnum

}


/// <summary>
/// Gets or Sets EnumStringRequired
/// </summary>
Expand All @@ -111,12 +113,36 @@ public enum EnumIntegerEnum

}


/// <summary>
/// Gets or Sets EnumInteger
/// </summary>
[DataMember(Name = "enum_integer", EmitDefaultValue = false)]
public EnumIntegerEnum? EnumInteger { get; set; }
/// <summary>
/// Defines EnumIntegerOnly
/// </summary>
public enum EnumIntegerOnlyEnum
{
/// <summary>
/// Enum NUMBER_2 for value: 2
/// </summary>
NUMBER_2 = 2,

/// <summary>
/// Enum NUMBER_MINUS_2 for value: -2
/// </summary>
NUMBER_MINUS_2 = -2

}


/// <summary>
/// Gets or Sets EnumIntegerOnly
/// </summary>
[DataMember(Name = "enum_integer_only", EmitDefaultValue = false)]
public EnumIntegerOnlyEnum? EnumIntegerOnly { get; set; }
/// <summary>
/// Defines EnumNumber
/// </summary>
[JsonConverter(typeof(StringEnumConverter))]
Expand All @@ -136,26 +162,31 @@ public enum EnumNumberEnum

}


/// <summary>
/// Gets or Sets EnumNumber
/// </summary>
[DataMember(Name = "enum_number", EmitDefaultValue = false)]
public EnumNumberEnum? EnumNumber { get; set; }

/// <summary>
/// Gets or Sets OuterEnum
/// </summary>
[DataMember(Name = "outerEnum", EmitDefaultValue = true)]
public OuterEnum? OuterEnum { get; set; }

/// <summary>
/// Gets or Sets OuterEnumInteger
/// </summary>
[DataMember(Name = "outerEnumInteger", EmitDefaultValue = false)]
public OuterEnumInteger? OuterEnumInteger { get; set; }

/// <summary>
/// Gets or Sets OuterEnumDefaultValue
/// </summary>
[DataMember(Name = "outerEnumDefaultValue", EmitDefaultValue = false)]
public OuterEnumDefaultValue? OuterEnumDefaultValue { get; set; }

/// <summary>
/// Gets or Sets OuterEnumIntegerDefaultValue
/// </summary>
Expand All @@ -175,16 +206,18 @@ protected EnumTest()
/// <param name="enumString">enumString.</param>
/// <param name="enumStringRequired">enumStringRequired (required).</param>
/// <param name="enumInteger">enumInteger.</param>
/// <param name="enumIntegerOnly">enumIntegerOnly.</param>
/// <param name="enumNumber">enumNumber.</param>
/// <param name="outerEnum">outerEnum.</param>
/// <param name="outerEnumInteger">outerEnumInteger.</param>
/// <param name="outerEnumDefaultValue">outerEnumDefaultValue.</param>
/// <param name="outerEnumIntegerDefaultValue">outerEnumIntegerDefaultValue.</param>
public EnumTest(EnumStringEnum? enumString = default(EnumStringEnum?), EnumStringRequiredEnum enumStringRequired = default(EnumStringRequiredEnum), EnumIntegerEnum? enumInteger = default(EnumIntegerEnum?), EnumNumberEnum? enumNumber = default(EnumNumberEnum?), OuterEnum? outerEnum = default(OuterEnum?), OuterEnumInteger? outerEnumInteger = default(OuterEnumInteger?), OuterEnumDefaultValue? outerEnumDefaultValue = default(OuterEnumDefaultValue?), OuterEnumIntegerDefaultValue? outerEnumIntegerDefaultValue = default(OuterEnumIntegerDefaultValue?))
public EnumTest(EnumStringEnum? enumString = default(EnumStringEnum?), EnumStringRequiredEnum enumStringRequired = default(EnumStringRequiredEnum), EnumIntegerEnum? enumInteger = default(EnumIntegerEnum?), EnumIntegerOnlyEnum? enumIntegerOnly = default(EnumIntegerOnlyEnum?), EnumNumberEnum? enumNumber = default(EnumNumberEnum?), OuterEnum? outerEnum = default(OuterEnum?), OuterEnumInteger? outerEnumInteger = default(OuterEnumInteger?), OuterEnumDefaultValue? outerEnumDefaultValue = default(OuterEnumDefaultValue?), OuterEnumIntegerDefaultValue? outerEnumIntegerDefaultValue = default(OuterEnumIntegerDefaultValue?))
{
this.EnumStringRequired = enumStringRequired;
this.EnumString = enumString;
this.EnumInteger = enumInteger;
this.EnumIntegerOnly = enumIntegerOnly;
this.EnumNumber = enumNumber;
this.OuterEnum = outerEnum;
this.OuterEnumInteger = outerEnumInteger;
Expand All @@ -210,6 +243,7 @@ public override string ToString()
sb.Append(" EnumString: ").Append(EnumString).Append("\n");
sb.Append(" EnumStringRequired: ").Append(EnumStringRequired).Append("\n");
sb.Append(" EnumInteger: ").Append(EnumInteger).Append("\n");
sb.Append(" EnumIntegerOnly: ").Append(EnumIntegerOnly).Append("\n");
sb.Append(" EnumNumber: ").Append(EnumNumber).Append("\n");
sb.Append(" OuterEnum: ").Append(OuterEnum).Append("\n");
sb.Append(" OuterEnumInteger: ").Append(OuterEnumInteger).Append("\n");
Expand Down Expand Up @@ -261,6 +295,7 @@ public override int GetHashCode()
hashCode = hashCode * 59 + this.EnumString.GetHashCode();
hashCode = hashCode * 59 + this.EnumStringRequired.GetHashCode();
hashCode = hashCode * 59 + this.EnumInteger.GetHashCode();
hashCode = hashCode * 59 + this.EnumIntegerOnly.GetHashCode();
hashCode = hashCode * 59 + this.EnumNumber.GetHashCode();
hashCode = hashCode * 59 + this.OuterEnum.GetHashCode();
hashCode = hashCode * 59 + this.OuterEnumInteger.GetHashCode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public enum InnerEnum
}



/// <summary>
/// Gets or Sets MapOfEnumString
/// </summary>
Expand Down
Loading