Skip to content

Fix SerializedMember JSON Schema to accept any value type#36

Merged
IvanMurzak merged 8 commits intomainfrom
copilot/fix-serialized-member-schema
Dec 7, 2025
Merged

Fix SerializedMember JSON Schema to accept any value type#36
IvanMurzak merged 8 commits intomainfrom
copilot/fix-serialized-member-schema

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 7, 2025

The JSON Schema for SerializedMember hardcoded the value property as type "object", but actual serialization produces primitives (string, number, boolean), arrays, objects, or null depending on the serialized type.

Example of the mismatch:

// Schema said:
{ "value": { "type": "object" } }

// But actual JSON was:
{ "value": "Hello World" }  // string
{ "value": 42 }             // number
{ "value": true }           // boolean

Changes

  • SerializedMemberConverter.cs: Removed type constraint from value property schema, allowing any JSON value type
  • SerializedMemberSchemaTests.cs: Added test coverage for schema validation and serialization of all value types (primitives, arrays, objects, null)

The schema now correctly represents the polymorphic nature of the value field.

Original prompt

This section details on the original issue you should resolve

<issue_title>SerializedMember should respect json schema</issue_title>
<issue_description>If SerializedMember represents System.String type and has the value, the 'value' property is a string value in the json. But JSON Schema of SerializedMember said it should be json object. It breaks the match with JSON Schema.

Need to figure out the solution when SerializedMember may represent any type and respect its own JSON Schema.

What could be a solution?</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits December 7, 2025 02:58
- Remove type constraint from 'value' property in SerializedMemberConverter.Schema
- Add comprehensive tests in SerializedMemberSchemaTests
- All 584 existing tests still pass

Co-authored-by: IvanMurzak <9135028+IvanMurzak@users.noreply.github.com>
- Extract numeric detection logic into separate IsNumericJsonValue method
- Add support for all numeric types (float, byte, short, uint, ulong, ushort, sbyte)

Co-authored-by: IvanMurzak <9135028+IvanMurzak@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix SerializedMember to respect JSON schema Fix SerializedMember JSON Schema to accept any value type Dec 7, 2025
Copilot AI requested a review from IvanMurzak December 7, 2025 03:04
@IvanMurzak IvanMurzak requested review from Copilot and removed request for IvanMurzak December 7, 2025 03:05
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Dec 7, 2025

Test Results

    3 files  ± 0      3 suites  ±0   3m 21s ⏱️ +28s
  595 tests +10    594 ✅ + 9  0 💤 ±0  1 ❌ +1 
1 747 runs  +30  1 746 ✅ +29  0 💤 ±0  1 ❌ +1 

For more details on these failures, see this check.

Results for commit 7f0a91a. ± Comparison against base commit 99c52b1.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Dec 7, 2025

Test Results

    3 files  ± 0      3 suites  ±0   3m 5s ⏱️ +12s
  595 tests +10    595 ✅ +10  0 💤 ±0  0 ❌ ±0 
1 747 runs  +30  1 747 ✅ +30  0 💤 ±0  0 ❌ ±0 

Results for commit 672865c. ± Comparison against base commit 99c52b1.

♻️ This comment has been updated with latest results.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a JSON Schema mismatch where the SerializedMember.value property was constrained to type "object" but actual serialization produces any JSON value type (primitives, arrays, objects, or null) depending on the serialized data.

  • Removed the hardcoded type: "object" constraint from the value property schema
  • Added comprehensive test coverage validating schema flexibility and serialization behavior across all JSON value types

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
ReflectorNet/src/Convertor/Json/SerializedMemberConverter.cs Removed the type: "object" constraint from the value property schema definition, allowing it to accept any JSON value type
ReflectorNet.Tests/src/SchemaTests/SerializedMemberSchemaTests.cs Added comprehensive test suite validating that the schema correctly accepts all value types (primitives, arrays, objects, null) and that serialization/deserialization works correctly for each type

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread ReflectorNet.Tests/src/SchemaTests/SerializedMemberSchemaTests.cs Outdated
@IvanMurzak IvanMurzak requested a review from Copilot December 7, 2025 08:22
@IvanMurzak IvanMurzak marked this pull request as ready for review December 7, 2025 08:22
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread ReflectorNet.Tests/src/SchemaTests/SerializedMemberSchemaTests.cs Outdated
Comment thread ReflectorNet/src/Utils/Json/JsonSerializer.cs
@IvanMurzak IvanMurzak merged commit 6702353 into main Dec 7, 2025
@IvanMurzak IvanMurzak deleted the copilot/fix-serialized-member-schema branch December 7, 2025 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SerializedMember should respect json schema

3 participants