Skip to content

Commit 8440549

Browse files
authored
Merge pull request #40 from contentstack/enhc/DX-9374
feat: migrate internal model DTOs from [JsonProperty] to [JsonPropertyName]
2 parents 81e34f0 + 70374c2 commit 8440549

7 files changed

Lines changed: 59 additions & 58 deletions

File tree

contentstack.model.generator/CMA/ContentStackError.cs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
using Newtonsoft.Json;
2-
using System;
1+
using System;
32
using System.Collections.Generic;
43
using System.Net;
5-
using System.Runtime.Serialization;
6-
4+
using System.Runtime.Serialization;
5+
using System.Text.Json.Serialization;
6+
77
namespace contentstack.CMA
88
{
99
/// <summary>
@@ -13,7 +13,7 @@ namespace contentstack.CMA
1313
public class ContentstackException : Exception
1414
{
1515
#region Private Variables
16-
private string _ErrorMessage = string.Empty;
16+
private string _ErrorMessage = string.Empty;
1717

1818
#endregion
1919

@@ -31,7 +31,7 @@ public class ContentstackException : Exception
3131
/// <summary>
3232
/// This is error message.
3333
/// </summary>
34-
[JsonProperty("error_message")]
34+
[JsonPropertyName("error_message")]
3535
public string ErrorMessage
3636
{
3737
get
@@ -48,13 +48,13 @@ public string ErrorMessage
4848
/// <summary>
4949
/// This is error code.
5050
/// </summary>
51-
[JsonProperty("error_code")]
51+
[JsonPropertyName("error_code")]
5252
public int ErrorCode { get; set; }
5353

5454
/// <summary>
5555
/// Set of errors in detail.
5656
/// </summary>
57-
[JsonProperty("errors")]
57+
[JsonPropertyName("errors")]
5858
public Dictionary<string, object> Errors { get; set; }
5959

6060
#endregion
@@ -85,21 +85,21 @@ public ContentstackException(Exception exception)
8585
: base(exception.Message, exception.InnerException)
8686
{
8787
this.ErrorMessage = exception.Message;
88-
}
89-
90-
protected ContentstackException(SerializationInfo info, StreamingContext context) : base(info, context)
91-
{
92-
}
93-
94-
public ContentstackException(string message, Exception innerException) : base(message, innerException)
95-
{
96-
}
97-
public override void GetObjectData(SerializationInfo info, StreamingContext context)
98-
{
99-
base.GetObjectData(info, context);
100-
}
88+
}
89+
90+
protected ContentstackException(SerializationInfo info, StreamingContext context) : base(info, context)
91+
{
92+
}
93+
94+
public ContentstackException(string message, Exception innerException) : base(message, innerException)
95+
{
96+
}
97+
public override void GetObjectData(SerializationInfo info, StreamingContext context)
98+
{
99+
base.GetObjectData(info, context);
100+
}
101101
#endregion
102102

103-
103+
104104
}
105105
}

contentstack.model.generator/CMA/OAuth/OAuthService.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Text;
66
using System.Threading.Tasks;
77
using Newtonsoft.Json;
8+
using System.Text.Json.Serialization;
89

910
namespace contentstack.CMA.OAuth
1011
{
@@ -408,25 +409,25 @@ internal static string GetDeveloperHubHostname(string baseHost)
408409

409410
public class OAuthTokenResponse
410411
{
411-
[JsonProperty("access_token")]
412+
[JsonPropertyName("access_token")]
412413
public string AccessToken { get; set; }
413414

414-
[JsonProperty("refresh_token")]
415+
[JsonPropertyName("refresh_token")]
415416
public string RefreshToken { get; set; }
416417

417-
[JsonProperty("token_type")]
418+
[JsonPropertyName("token_type")]
418419
public string TokenType { get; set; }
419420

420-
[JsonProperty("expires_in")]
421+
[JsonPropertyName("expires_in")]
421422
public int ExpiresIn { get; set; }
422423

423-
[JsonProperty("scope")]
424+
[JsonPropertyName("scope")]
424425
public string Scope { get; set; }
425426

426-
[JsonProperty("organization_uid")]
427+
[JsonPropertyName("organization_uid")]
427428
public string OrganizationUid { get; set; }
428429

429-
[JsonProperty("user_uid")]
430+
[JsonPropertyName("user_uid")]
430431
public string UserUid { get; set; }
431432

432433
// Computed property for expiration time

contentstack.model.generator/Model/Contenttype.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using System.Collections.Generic;
2-
using Newtonsoft.Json;
2+
using System.Text.Json.Serialization;
33

44
namespace contentstack.model.generator.Model
55
{
@@ -11,7 +11,7 @@ public class Contenttype
1111

1212
public List<Field> Schema { get; set; }
1313

14-
[JsonProperty(propertyName: "reference_to")]
14+
[JsonPropertyName("reference_to")]
1515
public string ReferenceTo { get; set; }
1616
}
1717
}

contentstack.model.generator/Model/Field.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
using System.Collections.Generic;
2-
using Newtonsoft.Json;
2+
using System.Text.Json.Serialization;
33

44
namespace contentstack.model.generator.Model
55
{
66
public class Field
77
{
8-
[JsonProperty(PropertyName = "display_name")]
8+
[JsonPropertyName("display_name")]
99
public string DisplayName { get; set; }
1010

1111
public string Uid { get; set; }
1212

13-
[JsonProperty(PropertyName = "data_type")]
13+
[JsonPropertyName("data_type")]
1414
public string DataType { get; set; }
1515

16-
[JsonProperty(PropertyName = "multiple")]
16+
[JsonPropertyName("multiple")]
1717
public bool IsMultiple { get; set; }
1818

19-
[JsonProperty(PropertyName = "reference_to")]
19+
[JsonPropertyName("reference_to")]
2020
public object ReferenceTo { get; set; }
2121

22-
[JsonProperty(PropertyName = "field_metadata")]
22+
[JsonPropertyName("field_metadata")]
2323
public MetaData FieldMetadata { get; set; }
2424

2525
public List<Contenttype> Blocks { get; set; }
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
using Newtonsoft.Json;
1+
using System.Text.Json.Serialization;
22

33
namespace contentstack.model.generator.Model
44
{
55
public class MetaData
66
{
7-
[JsonProperty(PropertyName = "ref_multiple")]
7+
[JsonPropertyName("ref_multiple")]
88
public bool RefMultiple { get; set; }
99

10-
[JsonProperty(PropertyName = "default_value")]
10+
[JsonPropertyName("default_value")]
1111
public object DefaultValue { get; set; }
1212

13-
[JsonProperty(PropertyName = "ref_multiple_content_types")]
13+
[JsonPropertyName("ref_multiple_content_types")]
1414
public bool RefMultipleContentType { get; set; }
1515

16-
[JsonProperty(PropertyName = "allow_rich_text")]
16+
[JsonPropertyName("allow_rich_text")]
1717
public bool IsRichText { get; set; }
1818

19-
[JsonProperty(PropertyName = "markdown")]
19+
[JsonPropertyName("markdown")]
2020
public bool IsMarkdown { get; set; }
2121

22-
[JsonProperty(PropertyName = "extension")]
22+
[JsonPropertyName("extension")]
2323
public bool IsExtension { get; set; }
2424

25-
[JsonProperty(PropertyName = "allow_json_rte")]
25+
[JsonPropertyName("allow_json_rte")]
2626
public bool IsJsonRTE { get; set; }
2727
}
2828
}

contentstack.model.generator/Model/OAuth.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3-
using Newtonsoft.Json;
3+
using System.Text.Json.Serialization;
44
using contentstack.model.generator.Model;
55

66
namespace Contentstack.Model.Generator.Model
@@ -11,7 +11,7 @@ namespace Contentstack.Model.Generator.Model
1111
public class OAuthAppAuthorizationResponse
1212
{
1313

14-
[JsonProperty("data")]
14+
[JsonPropertyName("data")]
1515
public OAuthAppAuthorizationData[] Data { get; set; }
1616
}
1717

@@ -21,19 +21,19 @@ public class OAuthAppAuthorizationResponse
2121
public class OAuthAppAuthorizationData
2222
{
2323

24-
[JsonProperty("authorization_uid")]
24+
[JsonPropertyName("authorization_uid")]
2525
public string AuthorizationUid { get; set; }
2626

2727

28-
[JsonProperty("user")]
28+
[JsonPropertyName("user")]
2929
public OAuthUser User { get; set; }
3030
}
3131

3232

3333
public class OAuthUser
3434
{
3535

36-
[JsonProperty("uid")]
36+
[JsonPropertyName("uid")]
3737
public string Uid { get; set; }
3838
}
3939

@@ -178,23 +178,23 @@ public override string ToString()
178178
public class OAuthResponse
179179
{
180180

181-
[JsonProperty("access_token")]
181+
[JsonPropertyName("access_token")]
182182
public string AccessToken { get; set; }
183183

184184

185-
[JsonProperty("refresh_token")]
185+
[JsonPropertyName("refresh_token")]
186186
public string RefreshToken { get; set; }
187187

188188

189-
[JsonProperty("expires_in")]
189+
[JsonPropertyName("expires_in")]
190190
public int ExpiresIn { get; set; }
191191

192192

193-
[JsonProperty("organization_uid")]
193+
[JsonPropertyName("organization_uid")]
194194
public string OrganizationUid { get; set; }
195195

196196

197-
[JsonProperty("user_uid")]
197+
[JsonPropertyName("user_uid")]
198198
public string UserUid { get; set; }
199199
}
200200
/// <summary>

contentstack.model.generator/Model/StackResponse.cs

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

44
namespace Contentstack.Model.Generator.Model
55
{
66
public class StackResponse
77
{
8-
[JsonProperty(PropertyName = "api_key")]
8+
[JsonPropertyName("api_key")]
99
public string APIKey { get; set; }
1010
public string Name { get; set; }
11-
[JsonProperty(PropertyName = "master_locale")]
11+
[JsonPropertyName("master_locale")]
1212
public string MasterLocale { get; set; }
1313
public string Uid { get; set; }
1414
public string Description { get; set; }

0 commit comments

Comments
 (0)