Skip to content

Commit 7670f60

Browse files
committed
feat: Migrate core Field models for ContentType support
1 parent 0ba1924 commit 7670f60

14 files changed

Lines changed: 69 additions & 79 deletions
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
using System;
2-
using Newtonsoft.Json;
2+
using System.Text.Json.Serialization;
33

44
namespace Contentstack.Management.Core.Models.Fields
55
{
66
public class DateField : Field
77
{
8-
[JsonProperty(propertyName: "startDate")]
8+
[JsonPropertyName("startDate")]
99
public string StartDate { get; set; }
10-
[JsonProperty(propertyName: "endDate")]
10+
[JsonPropertyName("endDate")]
1111
public string EndDate { get; set; }
1212
}
1313
}
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
using System;
22
using System.Collections.Generic;
3-
using Newtonsoft.Json;
3+
using System.Text.Json;
4+
using System.Text.Json.Serialization;
45

56
namespace Contentstack.Management.Core.Models.Fields
67
{
78
public class ExtensionField : Field
89
{
9-
[JsonProperty(propertyName: "extension_uid")]
10+
[JsonPropertyName("extension_uid")]
1011
public string extension_uid { get; set; }
11-
[JsonProperty(propertyName: "config")]
12-
public Dictionary<string, object> config { get; set; }
12+
[JsonPropertyName("config")]
13+
public Dictionary<string, JsonElement> config { get; set; }
1314
}
1415
}
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
11
using System;
22
using System.Collections.Generic;
3-
using Newtonsoft.Json;
3+
using System.Text.Json.Serialization;
44

55
namespace Contentstack.Management.Core.Models.Fields
66
{
77
public class FileField : Field
88
{
9-
[JsonProperty(propertyName: "extensions")]
9+
[JsonPropertyName("extensions")]
1010
public List<string> Extensions { get; set; }
11-
[JsonProperty(propertyName: "max")]
11+
[JsonPropertyName("max")]
1212
public int? Maxsize { get; set; }
13-
[JsonProperty(propertyName: "min")]
13+
[JsonPropertyName("min")]
1414
public int? MinSize { get; set; }
1515

1616
}
1717
public class ImageField : FileField
1818
{
19-
[JsonProperty(propertyName: "dimension")]
19+
[JsonPropertyName("dimension")]
2020
public Dimension Dimensions { get; set; }
2121
/// <summary>
2222
/// Allows you to enter additional data about a field. Also, you can add additional values under ‘field_metadata’.
2323
/// </summary>
24-
[JsonProperty(propertyName: "field_metadata")]
24+
[JsonPropertyName("field_metadata")]
2525
public new FileFieldMetadata FieldMetadata { get; set; }
2626
}
2727
public class Dimension
2828
{
29-
[JsonProperty(propertyName: "height")]
29+
[JsonPropertyName("height")]
3030
public Dictionary<string, int?> Height { get; set; }
31-
[JsonProperty(propertyName: "width")]
31+
[JsonPropertyName("width")]
3232
public Dictionary<string, int?> Width { get; set; }
3333
}
3434
}
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using System;
2-
using Newtonsoft.Json;
2+
using System.Text.Json.Serialization;
33

44
namespace Contentstack.Management.Core.Models.Fields
55
{
@@ -12,30 +12,30 @@ public class GlobalFieldReference : Field
1212
/// <summary>
1313
/// The UID of the global field being referenced.
1414
/// </summary>
15-
[JsonProperty(propertyName: "reference_to")]
15+
[JsonPropertyName("reference_to")]
1616
public string ReferenceTo { get; set; }
1717

1818
/// <summary>
1919
/// Determines if this field can accept multiple values.
2020
/// </summary>
21-
[JsonProperty(propertyName: "multiple")]
21+
[JsonPropertyName("multiple")]
2222
public new bool Multiple { get; set; }
2323

2424
/// <summary>
2525
/// Determines if this field is mandatory.
2626
/// </summary>
27-
[JsonProperty(propertyName: "mandatory")]
27+
[JsonPropertyName("mandatory")]
2828
public new bool Mandatory { get; set; }
2929

3030
/// <summary>
3131
/// Determines if this field value must be unique.
3232
/// </summary>
33-
[JsonProperty(propertyName: "unique")]
33+
[JsonPropertyName("unique")]
3434
public new bool Unique { get; set; }
3535
/// <summary>
3636
/// Determines if this field is non-localizable.
3737
/// </summary>
38-
[JsonProperty(propertyName: "non_localizable")]
38+
[JsonPropertyName("non_localizable")]
3939
public bool NonLocalizable { get; set; }
4040
}
4141
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
using System;
22
using System.Collections.Generic;
3-
using Newtonsoft.Json;
3+
using System.Text.Json.Serialization;
44

55
namespace Contentstack.Management.Core.Models.Fields
66
{
77
public class GroupField : Field
88
{
9-
[JsonProperty(propertyName: "format")]
9+
[JsonPropertyName("format")]
1010
public string Format { get; set; }
11-
[JsonProperty(propertyName: "schema")]
11+
[JsonPropertyName("schema")]
1212
public List<Field> Schema { get; set; }
13-
[JsonProperty(propertyName: "max_instance")]
13+
[JsonPropertyName("max_instance")]
1414
public int? MaxInstance { get; set; }
1515
}
1616
}
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using Newtonsoft.Json;
1+
using System.Text.Json;
2+
using System.Text.Json.Serialization;
23

34
namespace Contentstack.Management.Core.Models.Fields
45
{
@@ -7,7 +8,7 @@ namespace Contentstack.Management.Core.Models.Fields
78
/// </summary>
89
public class JsonField : TextboxField
910
{
10-
[JsonProperty(propertyName: "reference_to")]
11-
public object ReferenceTo { get; set; }
11+
[JsonPropertyName("reference_to")]
12+
public JsonElement? ReferenceTo { get; set; }
1213
}
1314
}
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
using System;
22
using System.Collections.Generic;
3-
using Newtonsoft.Json;
3+
using System.Text.Json.Serialization;
44

55
namespace Contentstack.Management.Core.Models.Fields
66
{
77
public class ModularBlockField : Field
88
{
9-
[JsonProperty(propertyName: "blocks")]
9+
[JsonPropertyName("blocks")]
1010
public List<Block> blocks { get; set; }
1111
}
1212

1313
public class Block
1414
{
15-
[JsonProperty(propertyName: "title")]
15+
[JsonPropertyName("title")]
1616
public string Title { get; set; }
17-
[JsonProperty(propertyName: "uid")]
17+
[JsonPropertyName("uid")]
1818
public string Uid { get; set; }
19-
[JsonProperty(propertyName: "autoEdit")]
19+
[JsonPropertyName("autoEdit")]
2020
public bool AutoEdit { get; set; }
21-
[JsonProperty(propertyName: "blockType")]
21+
[JsonPropertyName("blockType")]
2222
public bool BlockType { get; set; }
23-
[JsonProperty(propertyName: "schema")]
23+
[JsonPropertyName("schema")]
2424
public List<Field> Schema { get; set; }
2525
}
2626
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Newtonsoft.Json;
1+
using System.Text.Json.Serialization;
22

33
namespace Contentstack.Management.Core.Models.Fields
44
{
@@ -7,10 +7,10 @@ namespace Contentstack.Management.Core.Models.Fields
77
/// </summary>
88
public class NumberField : Field
99
{
10-
[JsonProperty(propertyName: "min")]
10+
[JsonPropertyName("min")]
1111
public int? Min { get; set; }
1212

13-
[JsonProperty(propertyName: "max")]
13+
[JsonPropertyName("max")]
1414
public int? Max { get; set; }
1515
}
1616
}
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
using System;
22
using System.Collections.Generic;
3-
using Newtonsoft.Json;
3+
using System.Text.Json;
4+
using System.Text.Json.Serialization;
45

56
namespace Contentstack.Management.Core.Models.Fields
67
{
78
public class ReferenceField : Field
89
{
9-
[JsonProperty(propertyName: "reference_to")]
10-
public object ReferenceTo { get; set; }
11-
[JsonProperty(propertyName: "plugins")]
10+
[JsonPropertyName("reference_to")]
11+
public JsonElement? ReferenceTo { get; set; }
12+
[JsonPropertyName("plugins")]
1213
public List<string> Plugins { get; set; }
1314
}
1415
}
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
using System;
22
using System.Collections.Generic;
3-
using Newtonsoft.Json;
3+
using System.Text.Json;
4+
using System.Text.Json.Serialization;
45

56
namespace Contentstack.Management.Core.Models.Fields
67
{
78
public class SelectField : Field
89
{
9-
[JsonProperty(propertyName: "enum")]
10+
[JsonPropertyName("enum")]
1011
public SelectEnum Enum { get; set; }
1112

1213
}
1314

1415
public class SelectEnum
1516
{
16-
[JsonProperty(propertyName: "advanced")]
17+
[JsonPropertyName("advanced")]
1718
public bool Advanced { get; set; }
1819

19-
[JsonProperty(propertyName: "choices")]
20-
public List<Dictionary<string, object>> Choices { get; set; }
20+
[JsonPropertyName("choices")]
21+
public List<Dictionary<string, JsonElement>> Choices { get; set; }
2122

2223
}
2324
}

0 commit comments

Comments
 (0)