Пример #1
0
        private string ParseEnum(string key, Newtonsoft.JsonV4.Schema.JsonSchema schema, IDictionary <string, ApiEnum> enums, string description)
        {
            var name = NetNamingMapper.GetObjectName(key);

            var apiEnum = new ApiEnum
            {
                Name        = name,
                Description = description,
                Values      = schema.Enum.Select(e => NetNamingMapper.GetEnumValueName(e.ToString())).ToList()
            };

            if (enums.ContainsKey(name))
            {
                if (IsAlreadyAdded(enums, apiEnum))
                {
                    return(name);
                }

                apiEnum.Name = UniquenessHelper.GetUniqueName(enums, name);
            }

            enums.Add(apiEnum.Name, apiEnum);

            return(apiEnum.Name);
        }
Пример #2
0
 private ApiEnum ParseEnum(ScalarShape scalar, IDictionary <string, ApiEnum> existingEnums, IDictionary <string, string> warnings, IDictionary <string, ApiEnum> newEnums)
 {
     return(new ApiEnum
     {
         Name = NetNamingMapper.GetObjectName(scalar.Name),
         Description = scalar.Description,
         Values = scalar.Values.Select(p => new PropertyBase {
             Name = NetNamingMapper.GetEnumValueName(p), OriginalName = p
         }).ToArray()
     });
 }
Пример #3
0
 public void Should_Not_Capitalize_Enum_Values()
 {
     Assert.AreEqual("i", NetNamingMapper.GetEnumValueName("i"));
 }