/// <summary>Gets a value indicating whether the validated data can be null.</summary> /// <param name="schemaType">The schema type.</param> /// <returns>true if the type can be null.</returns> public virtual bool IsNullable(SchemaType schemaType) { if (IsNullableRaw == true) { return(true); } if (IsEnumeration && Enumeration.Contains(null)) { return(true); } if (Type.HasFlag(JsonObjectType.Null)) { return(true); } if ((Type == JsonObjectType.None || Type.HasFlag(JsonObjectType.Null)) && OneOf.Any(o => o.IsNullable(schemaType))) { return(true); } if (ActualSchema != this && ActualSchema.IsNullable(schemaType)) { return(true); } if (ActualTypeSchema != this && ActualTypeSchema.IsNullable(schemaType)) { return(true); } return(false); }
/// <summary>Gets a value indicating whether the validated data can be null.</summary> /// <param name="schemaType">The schema type.</param> /// <returns>true if the type can be null.</returns> public virtual bool IsNullable(SchemaType schemaType) { if (schemaType == SchemaType.OpenApi3 && IsNullableRaw.HasValue) return IsNullableRaw.Value; if (IsEnumeration && Enumeration.Contains(null)) return true; if (Type.HasFlag(JsonObjectType.Null) && OneOf.Count == 0) return true; return (Type == JsonObjectType.None || Type.HasFlag(JsonObjectType.Null)) && OneOf.Any(o => o.IsNullable(schemaType)); }
/// <summary>Gets a value indicating whether the validated data can be null.</summary> /// <param name="schemaType">The schema type.</param> /// <returns>true if the type can be null.</returns> public virtual bool IsNullable(SchemaType schemaType) { if (IsEnumeration && Enumeration.Contains(null)) { return(true); } if (Type.HasFlag(JsonObjectType.Null) && OneOf.Count == 0) { return(true); } return((Type == JsonObjectType.None || Type.HasFlag(JsonObjectType.Null)) && OneOf.Any(o => o.IsNullable(schemaType))); }
/// <summary>Determines whether the specified property null handling is nullable.</summary> /// <param name="schemaType">The schema type.</param> /// <returns>true if the type can be null.</returns> public override bool IsNullable(SchemaType schemaType) { if (IsEnumeration && Enumeration.Contains(null)) { return(true); } if (schemaType == SchemaType.Swagger2) { return(IsRequired == false); } return(base.IsNullable(schemaType)); }
/// <summary>Determines whether the specified property null handling is nullable.</summary> /// <param name="nullHandling">The property null handling.</param> /// <returns></returns> public override bool IsNullable(NullHandling nullHandling) { if (IsEnumeration && Enumeration.Contains(null)) { return(true); } if (nullHandling == NullHandling.Swagger) { return(IsRequired == false); } return(base.IsNullable(nullHandling)); }