JsonSchemaAttribute.cs
2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
using System;
namespace UniJSON
{
public enum EnumSerializationType
{
AsInt,
AsString,
AsLowerString,
AsUpperString,
}
public class BaseJsonSchemaAttribute : Attribute
{
#region Annotation
public string Title;
public string Description;
#endregion
#region integer, number
public double Minimum = double.NaN;
public bool ExclusiveMinimum;
public double Maximum = double.NaN;
public bool ExclusiveMaximum;
public double MultipleOf;
#endregion
#region string
public string Pattern;
#endregion
#region array
public int MinItems;
public int MaxItems;
#endregion
#region object
public ValueNodeType ValueType;
public int MinProperties;
public bool Required;
public string[] Dependencies;
#endregion
#region enum
public EnumSerializationType EnumSerializationType;
public object[] EnumValues;
public object[] EnumExcludes;
#endregion
public PropertyExportFlags ExportFlags = PropertyExportFlags.Default;
/// <summary>
/// skip validator comparison
/// </summary>
public bool SkipSchemaComparison;
/// <summary>
/// Suppress errors if a value of the field which is not required by a schema is matched to this value.
/// This feature will be useful to ignore invalid value which is known.
/// </summary>
public object ExplicitIgnorableValue;
/// <summary>
/// Suppress errors if length of a value of the field which is not required by a schema is matched to this value.
/// This feature will be useful to ignore invalid value which is known.
/// </summary>
public int ExplicitIgnorableItemLength = -1;
public void Merge(BaseJsonSchemaAttribute rhs)
{
if (rhs == null) return;
if (string.IsNullOrEmpty(Title))
{
Title = rhs.Title;
}
}
}
public class JsonSchemaAttribute : BaseJsonSchemaAttribute { }
public class ItemJsonSchemaAttribute : BaseJsonSchemaAttribute { }
}