public TsZeroType GetTsNullability(PropertyInfo property)
        {
            if (property.PropertyType.IsValueType)
            {
                return(_defaultTo.GetTsNullability(property));
            }
            var nullability = property.ToContextualProperty().Nullability;

            return(nullability switch
            {
                Namotion.Reflection.Nullability.NotNullable => TsZeroType.None(),
                Namotion.Reflection.Nullability.Nullable => TsZeroType.Nullable(),
                Namotion.Reflection.Nullability.Unknown => _defaultTo.GetTsNullability(property),
                { } unknown => throw new InvalidOperationException(
                    $"Unknown value {unknown} for type {typeof(Namotion.Reflection.Nullability).FullName}")
            });
Example #2
0
        public TsZeroType GetTsNullability(PropertyInfo property)
        {
            var attr = JsonPropertyExtractor.Extract(property);
            var req  = attr?.Required();

            if (req.HasValue)
            {
                return(req.Value);
            }
            return(_defaultTo.GetTsNullability(property));
        }