Enhc/dx 8641#191
Draft
OMpawar-21 wants to merge 2 commits into
Draft
Conversation
- Replace all [JsonProperty] attributes with [JsonPropertyName] across all model classes (LabelModel, ExtensionModel, RoleModel, OAuthResponse, OAuthAppAuthorizationResponse, ExtensionScope, RoleModel nested classes, Token models) - Remove [JsonObject] attributes — null handling covered globally by DefaultIgnoreCondition = WhenWritingNull - Replace Newtonsoft JsonSerializer/JsonConverter with System.Text.Json equivalents in all service constructors and model classes - Migrate ParameterCollection.AddQuery(JObject) → AddQuery(JsonNode) and QueryParamValue.JObjectParameterValue to use JsonNode - Remove OpenJObjectResponse() from IResponse and ContentstackResponse — replaced by OpenJsonObjectResponse() (System.Text.Json.Nodes.JsonObject) - Rewrite NodeJsonConverterTest and TextNodeJsonConverterTest using STJ public API (JsonSerializer.Serialize/Deserialize) - Rewrite CustomJsonConverter mock from Newtonsoft JsonConverter base to JsonConverter<object> (STJ) - Migrate CustomWidgetModel scope serialization from JsonTextWriter to JsonSerializer.Serialize - Remove Newtonsoft.Json 13.0.3 package reference from core csproj - Re-enable all previously excluded model files (Role, Taxonomy, Term, Extension, Label, AuditLog, Webhook, Token, CustomExtension) and uncomment corresponding Stack accessor methods - Re-enable 4 excluded integration test files and fix missing using directives - Re-enable all 25 excluded unit test files; fix ArgumentException vs InvalidOperationException assertions for uid-empty guard methods - Enable OAuth: remove Compile Remove for OAuthHandler.cs and Services/OAuth, uncomment OAuth methods and EnsureOAuthTokenIsValidAsync in ContentstackClient - Fix service constructor calls in Term, Taxonomy, Webhook, Extension, AuditLog — remove legacy serializer first-arg pattern - Update unit test count: 991 → 1,242 tests all passing
Fix 1 — Role serialization (13 tests + Test057 as side-effect) New file: Contentstack.Management.Core/Utils/RuleJsonConverter.cs System.Text.Json only serializes the declared type when iterating a List<Rule>, so subclass fields like module and branches were silently dropped. The custom converter serializes the actual runtime type on Write, and dispatches on the "module" discriminator on Read. It uses the existing WithoutConverter<T>() helper to avoid infinite recursion. Edit: ContentstackClient.cs Initialize() Added SerializerOptions.Converters.Add(new RuleJsonConverter()) alongside the existing NodeJsonConverter and TextNodeJsonConverter registrations. Fix 2 — Extension upload wrong file type (3 tests) The Contentstack Extensions API requires an HTML source file. All three tests were uploading contentTypeSchema.json, which the API rejected with error_code 344: "upload: Not a valid html file". New file: Contentstack.Management.Core.Tests/Mock/extension.html Minimal valid HTML file accepted by the Extensions API. Edit: Contentstack013_AssetTest.cs Test002, Test003, Test004 — changed path from contentTypeSchema.json → extension.html and content type from "application/json" → "text/html".
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AuditLog,Extension,Label,Role,Taxonomy,Term,Webhook,DeliveryToken,ManagementToken, andCustomExtensionfully re-enabled with STJ attributes; all correspondingStack.*()accessor methods restored[JsonProperty]replaced with[JsonPropertyName]across all model classes;[JsonObject(ItemNullValueHandling)]removed in favour of globalDefaultIgnoreCondition = WhenWritingNullOAuthHandler,OAuthTokenService,OAuthAppAuthorizationService, andOAuthAppRevocationServicenow active; auto token refresh wired intoInvokeAsyncpipeline viaEnsureOAuthTokenIsValidAsyncJsonTextWritertoSystem.Text.Json.JsonSerializer.Serialize()Test002_Should_Create_Dashboard,Test003_Should_Create_Custom_Widget,Test004_Should_Create_Custom_field) now have real implementations usingextension.htmlsourceContentstack012b), DeliveryToken (Contentstack016), Taxonomy (Contentstack017), Role (Contentstack019)