/// <summary> /// /// </summary> /// <param name="swaggerDoc"></param> /// <param name="context"></param> public void Apply(Microsoft.OpenApi.Models.OpenApiDocument swaggerDoc, DocumentFilterContext context) { Dictionary <string, Type> dict = GetAllEnum(); foreach (var item in swaggerDoc.Components.Schemas) { var property = item.Value; var typeName = item.Key; Type itemType = null; if (property.Enum != null && property.Enum.Count > 0) { if (dict.ContainsKey(typeName)) { itemType = dict[typeName]; } else { itemType = null; } List <OpenApiInteger> list = new List <OpenApiInteger>(); foreach (var val in property.Enum) { list.Add((OpenApiInteger)val); } property.Description += DescribeEnum(itemType, list); } } }
public void Apply(Microsoft.OpenApi.Models.OpenApiDocument swaggerDoc, DocumentFilterContext context) { var dict = GetAllEnum(); foreach (var(typeName, property) in swaggerDoc.Components.Schemas) { try { Type itemType = null; if (property.Enum == null || property.Enum.Count <= 0) { continue; } itemType = dict.ContainsKey(typeName) ? dict[typeName] : null; var list = property.Enum.Cast <OpenApiInteger>().ToList(); property.Description += DescribeEnum(itemType, list); } catch { continue; } } }