forked from loafle/openapi-generator-original
Categorizing C# integration test for enums as general
This commit is contained in:
@@ -30,7 +30,7 @@ public class CsharpClientEnumRefIntegrationTest extends AbstractIntegrationTest
|
||||
|
||||
@Override
|
||||
protected IntegrationTestPathsConfig getIntegrationTestPathsConfig() {
|
||||
return new IntegrationTestPathsConfig("csharp/enum-ref");
|
||||
return new IntegrationTestPathsConfig("csharp/general/enum-ref");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,8 +12,8 @@ import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class CsharpClientInlineEnumIntegrationTest extends AbstractIntegrationTest {
|
||||
public CsharpClientInlineEnumIntegrationTest() {
|
||||
public class CsharpClientGeneralEnumSupportIntegrationTest extends AbstractIntegrationTest {
|
||||
public CsharpClientGeneralEnumSupportIntegrationTest() {
|
||||
generateSwaggerMetadata = false;
|
||||
|
||||
ImmutableMap.Builder<String, String> builder = new ImmutableMap.Builder<String, String>();
|
||||
@@ -30,7 +30,7 @@ public class CsharpClientInlineEnumIntegrationTest extends AbstractIntegrationTe
|
||||
|
||||
@Override
|
||||
protected IntegrationTestPathsConfig getIntegrationTestPathsConfig() {
|
||||
return new IntegrationTestPathsConfig("csharp/enum-inline");
|
||||
return new IntegrationTestPathsConfig("csharp/general/enum-support");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -46,7 +46,7 @@ public class CsharpClientInlineEnumIntegrationTest extends AbstractIntegrationTe
|
||||
}
|
||||
|
||||
// TODO: Remove this when super.generatesCorrectDirectoryStructure() is re-enabled.
|
||||
@Test(description = "Verify csharp enums as ref properties")
|
||||
@Test(description = "Verify csharp enum support, generalized across supported C# versions.")
|
||||
public void test() throws IOException {
|
||||
this.generatesCorrectDirectoryStructure();
|
||||
}
|
||||
@@ -30,68 +30,18 @@ namespace IO.Swagger.Model
|
||||
[DataContract]
|
||||
public partial class MyClassWithOptionalEnum : IEquatable<MyClassWithOptionalEnum>, IValidatableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or Sets Days
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public enum DaysEnum
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Enum Sun for "sun"
|
||||
/// </summary>
|
||||
[EnumMember(Value = "sun")]
|
||||
Sun,
|
||||
|
||||
/// <summary>
|
||||
/// Enum Mon for "mon"
|
||||
/// </summary>
|
||||
[EnumMember(Value = "mon")]
|
||||
Mon,
|
||||
|
||||
/// <summary>
|
||||
/// Enum Tue for "tue"
|
||||
/// </summary>
|
||||
[EnumMember(Value = "tue")]
|
||||
Tue,
|
||||
|
||||
/// <summary>
|
||||
/// Enum Wed for "wed"
|
||||
/// </summary>
|
||||
[EnumMember(Value = "wed")]
|
||||
Wed,
|
||||
|
||||
/// <summary>
|
||||
/// Enum Thu for "thu"
|
||||
/// </summary>
|
||||
[EnumMember(Value = "thu")]
|
||||
Thu,
|
||||
|
||||
/// <summary>
|
||||
/// Enum Fri for "fri"
|
||||
/// </summary>
|
||||
[EnumMember(Value = "fri")]
|
||||
Fri,
|
||||
|
||||
/// <summary>
|
||||
/// Enum Sat for "sat"
|
||||
/// </summary>
|
||||
[EnumMember(Value = "sat")]
|
||||
Sat
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Days
|
||||
/// </summary>
|
||||
[DataMember(Name="days", EmitDefaultValue=false)]
|
||||
public DaysEnum? Days { get; set; }
|
||||
public WeekDays? Days { get; set; }
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MyClassWithOptionalEnum" /> class.
|
||||
/// </summary>
|
||||
/// <param name="Quarantine">Quarantine.</param>
|
||||
/// <param name="Grayware">Grayware.</param>
|
||||
/// <param name="Days">Days.</param>
|
||||
public MyClassWithOptionalEnum(bool? Quarantine = default(bool?), bool? Grayware = default(bool?), DaysEnum? Days = default(DaysEnum?))
|
||||
public MyClassWithOptionalEnum(bool? Quarantine = default(bool?), bool? Grayware = default(bool?), WeekDays? Days = default(WeekDays?))
|
||||
{
|
||||
this.Quarantine = Quarantine;
|
||||
this.Grayware = Grayware;
|
||||
@@ -0,0 +1,206 @@
|
||||
/*
|
||||
* My title
|
||||
*
|
||||
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
|
||||
*
|
||||
* OpenAPI spec version: 1
|
||||
*
|
||||
* Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Runtime.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter;
|
||||
|
||||
namespace IO.Swagger.Model
|
||||
{
|
||||
/// <summary>
|
||||
/// MyClassWithOptionalInlineEnum
|
||||
/// </summary>
|
||||
[DataContract]
|
||||
public partial class MyClassWithOptionalInlineEnum : IEquatable<MyClassWithOptionalInlineEnum>, IValidatableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or Sets Days
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public enum DaysEnum
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Enum Sun for "sun"
|
||||
/// </summary>
|
||||
[EnumMember(Value = "sun")]
|
||||
Sun,
|
||||
|
||||
/// <summary>
|
||||
/// Enum Mon for "mon"
|
||||
/// </summary>
|
||||
[EnumMember(Value = "mon")]
|
||||
Mon,
|
||||
|
||||
/// <summary>
|
||||
/// Enum Tue for "tue"
|
||||
/// </summary>
|
||||
[EnumMember(Value = "tue")]
|
||||
Tue,
|
||||
|
||||
/// <summary>
|
||||
/// Enum Wed for "wed"
|
||||
/// </summary>
|
||||
[EnumMember(Value = "wed")]
|
||||
Wed,
|
||||
|
||||
/// <summary>
|
||||
/// Enum Thu for "thu"
|
||||
/// </summary>
|
||||
[EnumMember(Value = "thu")]
|
||||
Thu,
|
||||
|
||||
/// <summary>
|
||||
/// Enum Fri for "fri"
|
||||
/// </summary>
|
||||
[EnumMember(Value = "fri")]
|
||||
Fri,
|
||||
|
||||
/// <summary>
|
||||
/// Enum Sat for "sat"
|
||||
/// </summary>
|
||||
[EnumMember(Value = "sat")]
|
||||
Sat
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Days
|
||||
/// </summary>
|
||||
[DataMember(Name="days", EmitDefaultValue=false)]
|
||||
public DaysEnum? Days { get; set; }
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MyClassWithOptionalInlineEnum" /> class.
|
||||
/// </summary>
|
||||
/// <param name="Quarantine">Quarantine.</param>
|
||||
/// <param name="Grayware">Grayware.</param>
|
||||
/// <param name="Days">Days.</param>
|
||||
public MyClassWithOptionalInlineEnum(bool? Quarantine = default(bool?), bool? Grayware = default(bool?), DaysEnum? Days = default(DaysEnum?))
|
||||
{
|
||||
this.Quarantine = Quarantine;
|
||||
this.Grayware = Grayware;
|
||||
this.Days = Days;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Quarantine
|
||||
/// </summary>
|
||||
[DataMember(Name="quarantine", EmitDefaultValue=false)]
|
||||
public bool? Quarantine { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Grayware
|
||||
/// </summary>
|
||||
[DataMember(Name="grayware", EmitDefaultValue=false)]
|
||||
public bool? Grayware { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns the string presentation of the object
|
||||
/// </summary>
|
||||
/// <returns>String presentation of the object</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.Append("class MyClassWithOptionalInlineEnum {\n");
|
||||
sb.Append(" Quarantine: ").Append(Quarantine).Append("\n");
|
||||
sb.Append(" Grayware: ").Append(Grayware).Append("\n");
|
||||
sb.Append(" Days: ").Append(Days).Append("\n");
|
||||
sb.Append("}\n");
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the JSON string presentation of the object
|
||||
/// </summary>
|
||||
/// <returns>JSON string presentation of the object</returns>
|
||||
public string ToJson()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this, Formatting.Indented);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if objects are equal
|
||||
/// </summary>
|
||||
/// <param name="input">Object to be compared</param>
|
||||
/// <returns>Boolean</returns>
|
||||
public override bool Equals(object input)
|
||||
{
|
||||
return this.Equals(input as MyClassWithOptionalInlineEnum);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if MyClassWithOptionalInlineEnum instances are equal
|
||||
/// </summary>
|
||||
/// <param name="input">Instance of MyClassWithOptionalInlineEnum to be compared</param>
|
||||
/// <returns>Boolean</returns>
|
||||
public bool Equals(MyClassWithOptionalInlineEnum input)
|
||||
{
|
||||
if (input == null)
|
||||
return false;
|
||||
|
||||
return
|
||||
(
|
||||
this.Quarantine == input.Quarantine ||
|
||||
(this.Quarantine != null &&
|
||||
this.Quarantine.Equals(input.Quarantine))
|
||||
) &&
|
||||
(
|
||||
this.Grayware == input.Grayware ||
|
||||
(this.Grayware != null &&
|
||||
this.Grayware.Equals(input.Grayware))
|
||||
) &&
|
||||
(
|
||||
this.Days == input.Days ||
|
||||
(this.Days != null &&
|
||||
this.Days.Equals(input.Days))
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the hash code
|
||||
/// </summary>
|
||||
/// <returns>Hash code</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
unchecked // Overflow is fine, just wrap
|
||||
{
|
||||
int hashCode = 41;
|
||||
if (this.Quarantine != null)
|
||||
hashCode = hashCode * 59 + this.Quarantine.GetHashCode();
|
||||
if (this.Grayware != null)
|
||||
hashCode = hashCode * 59 + this.Grayware.GetHashCode();
|
||||
if (this.Days != null)
|
||||
hashCode = hashCode * 59 + this.Days.GetHashCode();
|
||||
return hashCode;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// To validate all properties of the instance
|
||||
/// </summary>
|
||||
/// <param name="validationContext">Validation context</param>
|
||||
/// <returns>Validation Result</returns>
|
||||
IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* My title
|
||||
*
|
||||
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
|
||||
*
|
||||
* OpenAPI spec version: 1
|
||||
*
|
||||
* Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Runtime.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter;
|
||||
|
||||
namespace IO.Swagger.Model
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines WeekDays
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public enum WeekDays
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Enum Sun for "sun"
|
||||
/// </summary>
|
||||
[EnumMember(Value = "sun")]
|
||||
Sun,
|
||||
|
||||
/// <summary>
|
||||
/// Enum Mon for "mon"
|
||||
/// </summary>
|
||||
[EnumMember(Value = "mon")]
|
||||
Mon,
|
||||
|
||||
/// <summary>
|
||||
/// Enum Tue for "tue"
|
||||
/// </summary>
|
||||
[EnumMember(Value = "tue")]
|
||||
Tue,
|
||||
|
||||
/// <summary>
|
||||
/// Enum Wed for "wed"
|
||||
/// </summary>
|
||||
[EnumMember(Value = "wed")]
|
||||
Wed,
|
||||
|
||||
/// <summary>
|
||||
/// Enum Thu for "thu"
|
||||
/// </summary>
|
||||
[EnumMember(Value = "thu")]
|
||||
Thu,
|
||||
|
||||
/// <summary>
|
||||
/// Enum Fri for "fri"
|
||||
/// </summary>
|
||||
[EnumMember(Value = "fri")]
|
||||
Fri,
|
||||
|
||||
/// <summary>
|
||||
/// Enum Sat for "sat"
|
||||
/// </summary>
|
||||
[EnumMember(Value = "sat")]
|
||||
Sat
|
||||
}
|
||||
|
||||
}
|
||||
@@ -33,7 +33,32 @@
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"WeekDays": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"sun",
|
||||
"mon",
|
||||
"tue",
|
||||
"wed",
|
||||
"thu",
|
||||
"fri",
|
||||
"sat"
|
||||
]
|
||||
},
|
||||
"My_Class_With_Optional_Enum": {
|
||||
"properties": {
|
||||
"quarantine": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"grayware": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"days": {
|
||||
"$ref": "#/definitions/WeekDays"
|
||||
}
|
||||
}
|
||||
},
|
||||
"My_Class_With_Optional_Inline_Enum": {
|
||||
"properties": {
|
||||
"quarantine": {
|
||||
"type": "boolean"
|
||||
Reference in New Issue
Block a user