public static string ToDataType()

in src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Extensions/EnumExtensions.cs [51:111]


        public static string ToDataType(this Type type)
        {
            var @enum = Type.GetTypeCode(type);
            if (!type.IsNullOrDefault() && type.IsEnum)
            {
                @enum = TypeCode.String;
            }

            switch (@enum)
            {
                case TypeCode.Int16:
                case TypeCode.Int32:
                case TypeCode.Int64:
                    return "integer";

                case TypeCode.Single:
                case TypeCode.Double:
                case TypeCode.Decimal:
                    return "number";

                case TypeCode.Boolean:
                    return "boolean";

                case TypeCode.DateTime:
                case TypeCode.String:
                    return "string";

                case TypeCode.Object:
                    if (type == typeof(Guid))
                    {
                        return "string";
                    }
                    else if (type == typeof(DateTime))
                    {
                        return "string";
                    }
                    else if (type == typeof(DateTimeOffset))
                    {
                        return "string";
                    }
                    else if (type == typeof(TimeSpan))
                    {
                        return "string";
                    }
                    else
                    {
                        return "object";
                    }

                case TypeCode.Empty:
                case TypeCode.DBNull:
                case TypeCode.Char:
                case TypeCode.SByte:
                case TypeCode.Byte:
                case TypeCode.UInt16:
                case TypeCode.UInt32:
                case TypeCode.UInt64:
                default:
                    throw new InvalidOperationException("Invalid data type");
            }
        }