public static string ToDataFormat()

in src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Extensions/EnumExtensions.cs [118:182]


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

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

                case TypeCode.Int64:
                    return "int64";

                case TypeCode.Single:
                    return "float";

                case TypeCode.Double:
                case TypeCode.Decimal:
                    return "double";

                case TypeCode.DateTime:
                    return "date-time";

                case TypeCode.Char:
                case TypeCode.SByte:
                case TypeCode.Byte:
                case TypeCode.UInt16:
                case TypeCode.UInt32:
                case TypeCode.UInt64:
                case TypeCode.Boolean:
                case TypeCode.String:
                    return null;

                case TypeCode.Object:
                    if (type == typeof(Guid))
                    {
                        return "uuid";
                    }
                    else if (type == typeof(DateTime))
                    {
                        return "date-time";
                    }
                    else if (type == typeof(DateTimeOffset))
                    {
                        return "date-time";
                    }
                    else if (type == typeof(TimeSpan))
                    {
                        return "timespan";
                    }
                    else
                    {
                        return null;
                    }

                case TypeCode.Empty:
                case TypeCode.DBNull:
                default:
                    throw new InvalidOperationException("Invalid data type");
            }
        }