diff --git a/src/SwaggerWcf/Models/DefinitionProperty.cs b/src/SwaggerWcf/Models/DefinitionProperty.cs index b708ca8..ff496c4 100644 --- a/src/SwaggerWcf/Models/DefinitionProperty.cs +++ b/src/SwaggerWcf/Models/DefinitionProperty.cs @@ -53,7 +53,7 @@ public DefinitionProperty() public bool UniqueItems { get; set; } - public List Enum { get; set; } + public List Enum { get; set; } public decimal MultipleOf { get; set; } @@ -155,7 +155,7 @@ public void Serialize(JsonWriter writer) { writer.WritePropertyName("enum"); writer.WriteStartArray(); - foreach (int e in Enum) + foreach (string e in Enum) { writer.WriteValue(e); } diff --git a/src/SwaggerWcf/Models/DefinitionSchema.cs b/src/SwaggerWcf/Models/DefinitionSchema.cs index a1e9d15..34a4915 100644 --- a/src/SwaggerWcf/Models/DefinitionSchema.cs +++ b/src/SwaggerWcf/Models/DefinitionSchema.cs @@ -22,7 +22,7 @@ internal class DefinitionSchema public List Properties { get; set; } - public List Enum { get; set; } + public List Enum { get; set; } public void Serialize(JsonWriter writer) { @@ -86,7 +86,7 @@ public void Serialize(JsonWriter writer) { writer.WritePropertyName("enum"); writer.WriteStartArray(); - foreach (int e in Enum) + foreach (string e in Enum) { writer.WriteValue(e); } diff --git a/src/SwaggerWcf/Support/DefinitionsBuilder.cs b/src/SwaggerWcf/Support/DefinitionsBuilder.cs index 7988c42..9ab9aac 100644 --- a/src/SwaggerWcf/Support/DefinitionsBuilder.cs +++ b/src/SwaggerWcf/Support/DefinitionsBuilder.cs @@ -67,7 +67,7 @@ private static Definition ConvertTypeToDefinition(Type definitionType, IList(); + schema.Enum = new List(); Type propType = definitionType; @@ -215,14 +215,14 @@ public static void ApplyAttributeOptions(IEnumerable a._MultipleOf), x => prop.MultipleOf = x.Value); } - public static int GetEnumMemberValue(Type enumType, string enumName) + public static string GetEnumMemberValue(Type enumType, string enumName) { if (string.IsNullOrWhiteSpace(enumName)) - return 0; + return ""; var enumVal = Enum.Parse(enumType, enumName, true); var underlyingType = Enum.GetUnderlyingType(enumType); - var val = Convert.ChangeType(enumVal, underlyingType); - return Convert.ToInt32(val); + var val = enumName;//Convert.ChangeType(enumVal, underlyingType); + return val; } public static string GetEnumDescription(Enum value) diff --git a/src/SwaggerWcf/Support/Helpers.cs b/src/SwaggerWcf/Support/Helpers.cs index 168acaa..26de0fa 100644 --- a/src/SwaggerWcf/Support/Helpers.cs +++ b/src/SwaggerWcf/Support/Helpers.cs @@ -95,7 +95,7 @@ public static TypeFormat MapSwaggerType(Type type, IList definitions = nul //it's an enum, use string as the property type and enum values will be serialized later if (type.IsEnum) { - return new TypeFormat(ParameterType.Integer, "enum"); + return new TypeFormat(ParameterType.String, "enum"); } //it's a collection/array, so it will use the swagger "container" syntax diff --git a/src/SwaggerWcf/Support/TypeFieldsProcessor.cs b/src/SwaggerWcf/Support/TypeFieldsProcessor.cs index 7c6d9d0..529da6b 100644 --- a/src/SwaggerWcf/Support/TypeFieldsProcessor.cs +++ b/src/SwaggerWcf/Support/TypeFieldsProcessor.cs @@ -130,7 +130,7 @@ private static DefinitionProperty ProcessField(FieldInfo propertyInfo, IList(); + prop.Enum = new List(); Type propType = propertyInfo.FieldType; @@ -144,7 +144,7 @@ private static DefinitionProperty ProcessField(FieldInfo propertyInfo, IList(); + prop.Enum = new List(); Type propType = propertyInfo.PropertyType; @@ -144,7 +144,7 @@ private static DefinitionProperty ProcessProperty(PropertyInfo propertyInfo, ILi var enumMemberItem = Enum.Parse(propType, enumName, true); string enumMemberDescription = DefinitionsBuilder.GetEnumDescription((Enum)enumMemberItem); enumMemberDescription = (string.IsNullOrWhiteSpace(enumMemberDescription)) ? "" : $"({enumMemberDescription})"; - int enumMemberValue = DefinitionsBuilder.GetEnumMemberValue(propType, enumName); + string enumMemberValue = DefinitionsBuilder.GetEnumMemberValue(propType, enumName); if (prop.Description != null) prop.Enum.Add(enumMemberValue); enumDescription += $" {enumName}{System.Web.HttpUtility.HtmlEncode(" = ")}{enumMemberValue} {enumMemberDescription}\r\n"; } diff --git a/src/SwaggerWcf/www/swagger-ui.zip b/src/SwaggerWcf/www/swagger-ui.zip index f4723f4..16fb593 100644 Binary files a/src/SwaggerWcf/www/swagger-ui.zip and b/src/SwaggerWcf/www/swagger-ui.zip differ