Skip to content

Commit 768b780

Browse files
authored
Merge pull request #29 from contentstack/fix/CS-43474-Adds-JsonConverters-for-Node-TextNode
Fix: adds json converters for Node and TextNode of JSON RTE components
2 parents 45bcf4a + 03c672a commit 768b780

19 files changed

+336
-16
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Changelog
22

3+
## [v0.1.5](https://github.com/contentstack/contentstack-management-dotnet/tree/v0.1.5) (2024-02-11)
4+
- Adds JsonConverters to Serializer for JSON Rte
5+
36
## [v0.1.4](https://github.com/contentstack/contentstack-management-dotnet/tree/v0.1.4) (2024-01-22)
7+
- EarlyAccess Header support and AddQuery method in ParamCollection
48

59
## [v0.1.3](https://github.com/contentstack/contentstack-management-dotnet/tree/v0.1.3) (2023-04-04)
610

Contentstack.Management.ASPNETCore/LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright © 2012-2021 Contentstack. All Rights Reserved
3+
Copyright © 2012-2024 Contentstack. All Rights Reserved
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

Contentstack.Management.ASPNETCore/contentstack.management.aspnetcore.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
<PropertyGroup>
44
<TargetFramework>netstandard2.1</TargetFramework>
55
<PackageId>contentstack.management.aspnetcore</PackageId>
6-
<PackageVersion>0.1.4</PackageVersion>
6+
<PackageVersion>0.1.5</PackageVersion>
77
<Authors>Contentstack</Authors>
8-
<Copyright>Copyright © 2012-2023 Contentstack. All Rights Reserved</Copyright>
8+
<Copyright>Copyright © 2012-2024 Contentstack. All Rights Reserved</Copyright>
99
<Owners>Contentstack </Owners>
1010
<PackageProjectUrl>https://github.com/contentstack/contentstack-management-dotnet</PackageProjectUrl>
1111
<PackageReleaseNotes>Initial Release</PackageReleaseNotes>
@@ -14,8 +14,8 @@
1414
<Title>Contentstack Management</Title>
1515
<Description>.NET SDK for the Contentstack Content Management API.</Description>
1616
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
17-
<PackageTags>v0.1.4</PackageTags>
18-
<ReleaseVersion>0.1.4</ReleaseVersion>
17+
<PackageTags>v0.1.5</PackageTags>
18+
<ReleaseVersion>0.1.5</ReleaseVersion>
1919
<RootNamespace>Contentstack.Management.ASPNETCore</RootNamespace>
2020
</PropertyGroup>
2121

Contentstack.Management.Core.Tests/Contentstack.Management.Core.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<TargetFramework>net7.0</TargetFramework>
55

66
<IsPackable>false</IsPackable>
7-
<ReleaseVersion>0.1.4</ReleaseVersion>
7+
<ReleaseVersion>0.1.3</ReleaseVersion>
88
</PropertyGroup>
99

1010
<ItemGroup>
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using Contentstack.Management.Core.Models;
4+
using Contentstack.Management.Core.Utils;
5+
using Contentstack.Management.Core.Tests.Model;
6+
using Microsoft.VisualStudio.TestTools.UnitTesting;
7+
using Newtonsoft.Json;
8+
9+
10+
namespace Contentstack.Management.Core.Tests.IntegrationTest
11+
{
12+
[TestClass]
13+
public class Contentstack007_EntryTest
14+
{
15+
private Stack _stack;
16+
17+
[TestInitialize]
18+
public void Initialize()
19+
{
20+
StackResponse response = StackResponse.getStack(Contentstack.Client.serializer);
21+
_stack = Contentstack.Client.Stack(response.Stack.APIKey);
22+
}
23+
24+
[TestMethod]
25+
[DoNotParallelize]
26+
public async System.Threading.Tasks.Task Test001_Should_Create_Entry()
27+
{
28+
PageJSONRTE pg = new PageJSONRTE()
29+
{
30+
Title = "My First JSON-Rte Entry",
31+
RteData = new Node
32+
{
33+
type = "doc",
34+
children = new List<Node>
35+
{
36+
new Node
37+
{
38+
type = "p",
39+
attrs = new Dictionary<string, object>
40+
{
41+
{"style", new Object() },
42+
{"redactor-attributes", new Object() },
43+
{"dir", "ltr" }
44+
},
45+
children = new List<Node>
46+
{
47+
new TextNode
48+
{
49+
text = "My new text",
50+
attrs = null,
51+
type = "text"
52+
}
53+
}
54+
}
55+
},
56+
attrs = null
57+
}
58+
59+
};
60+
//JsonSerializer js = new JsonSerializer();
61+
//js.Converters.Add(new NodeJsonConverter);
62+
//js.Serialize();
63+
64+
try
65+
{
66+
ContentstackResponse response = await _stack.ContentType("page_json_rte").Entry().CreateAsync(pg);
67+
Assert.AreEqual(System.Net.HttpStatusCode.Created, response.StatusCode);
68+
}catch (Exception e)
69+
{
70+
Assert.Fail(e.Data+ e.Message);
71+
}
72+
}
73+
74+
}
75+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using Contentstack.Management.Core.Models;
2+
using Newtonsoft.Json;
3+
using Contentstack.Management.Core.Abstractions;
4+
5+
namespace Contentstack.Management.Core.Tests.Model
6+
{
7+
public partial class PageJSONRTE : IEntry
8+
{
9+
public const string ContentType = "page_json_rte";
10+
11+
[JsonProperty(propertyName: "uid")]
12+
public string Uid { get; set; }
13+
[JsonProperty(propertyName: "_content_type_uid")]
14+
public string ContentTypeUid { get; set; }
15+
public string Title { get; set; }
16+
[JsonProperty(propertyName: "rte_data")]
17+
public Node RteData { get; set; }
18+
}
19+
}

Contentstack.Management.Core.Unit.Tests/Contentstack.Management.Core.Unit.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<TargetFramework>net7.0</TargetFramework>
55

66
<IsPackable>false</IsPackable>
7-
<ReleaseVersion>0.1.4</ReleaseVersion>
7+
<ReleaseVersion>0.1.5</ReleaseVersion>
88
</PropertyGroup>
99

1010
<ItemGroup>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 25.0.1706.7
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Contentstack.Management.Core.Unit.Tests", "Contentstack.Management.Core.Unit.Tests.csproj", "{E538B868-3CEC-41D0-8D3F-F35D9A317BF8}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{E538B868-3CEC-41D0-8D3F-F35D9A317BF8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{E538B868-3CEC-41D0-8D3F-F35D9A317BF8}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{E538B868-3CEC-41D0-8D3F-F35D9A317BF8}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{E538B868-3CEC-41D0-8D3F-F35D9A317BF8}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {04680C0E-4E3F-4CD1-ABD4-33B468E70E84}
24+
EndGlobalSection
25+
EndGlobal

Contentstack.Management.Core/ContentstackClient.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class ContentstackClient : IContentstackClient
3535
private HttpClient _httpClient;
3636
private bool _disposed = false;
3737

38-
private string Version => "0.1.4";
38+
private string Version => "0.1.5";
3939
private string xUserAgent => $"contentstack-management-dotnet/{Version}";
4040
#endregion
4141

@@ -163,6 +163,8 @@ protected void Initialize()
163163
{
164164
SerializerSettings.Converters.Add((JsonConverter)Activator.CreateInstance(t));
165165
}
166+
SerializerSettings.Converters.Add(new NodeJsonConverter());
167+
SerializerSettings.Converters.Add(new TextNodeJsonConverter());
166168
}
167169

168170
protected void BuildPipeline()

Contentstack.Management.Core/LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright © 2012-2021 Contentstack. All Rights Reserved
3+
Copyright © 2012-2024 Contentstack. All Rights Reserved
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

0 commit comments

Comments
 (0)