Enhance JSON schema generation with $defs support and 'result' property#17
Enhance JSON schema generation with $defs support and 'result' property#17IvanMurzak merged 24 commits intomainfrom
Conversation
…ypes and add 'result' property
There was a problem hiding this comment.
Pull Request Overview
Enhance JSON schema generation to support $defs for complex types and wrap method return schemas in an object with a "result" property. Also bumps package version to 2.1.1.
- Add GenerateSchemaWithDefs to centralize $defs handling and deduplicate complex type schemas
- Update GetArgumentsSchema and GetReturnSchema to use $defs and introduce the "result" property in return schemas
- Introduce JsonSchema.Result constant and update tests to reflect the new return schema shape
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| ReflectorNet/src/Utils/Json/JsonSchema.cs | Adds $defs-aware schema generation and wraps return schemas with "result" property |
| ReflectorNet/src/Utils/Json/JsonSchema.Consts.cs | Adds Result constant used in new return schema shape |
| ReflectorNet/ReflectorNet.csproj | Version bump to 2.1.1 |
| ReflectorNet.Tests/SchemaTests/ReturnSchemaTests.cs | Updates tests to validate "result" wrapper and $defs behavior |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
…types in JSON schema generation
- Consolidated void return type tests into a single theory with inline data for void, Task, and ValueTask methods. - Combined primitive return type tests into a single theory with inline data for string, int, bool, and double methods. - Merged nullable primitive return type tests into a single theory with inline data for nullable types. - Unified task primitive unwrapping tests into a single theory with inline data for task methods. - Streamlined nullable task primitive unwrapping tests into a single theory with inline data. - Refactored value task unwrapping tests into a single theory with inline data for value task methods. - Added helper methods in SchemaTestBase for asserting return schema structures, including primitive, custom type, and array schemas.
… usings in ReturnSchemaTests
…ate unwrapping and schema generation
…hema $defs section
…ference for expected types
- Updated method parameter type ID retrieval from GetTypeId to GetSchemaTypeId in SchemaTestBase. - Enhanced AssertResultDefines to filter expected types, ensuring only non-primitive and non-enum types are included in $defs. - Added comprehensive tests for GetSchemaTypeId covering various collection types, nullable types, and custom classes in TestSchemaTypeId. - Introduced JsonObjectBuilder for building JSON schema objects with methods for adding properties, definitions, and handling required fields. - Updated TypeUtils to include GetSchemaTypeId method for consistent schema type ID generation. - Modified converters (MethodDataConverter, SerializedMemberConverter, SerializedMemberListConverter) to use GetSchemaTypeId for static ID retrieval. - Adjusted JsonSchema to utilize GetSchemaTypeId for reference handling and type definitions. - Commented out a test in TestType to avoid issues with current assembly type resolution.
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 27 out of 27 changed files in this pull request and generated 5 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
…schema $defs section
- Added IJsonSchemaConverter interface to define methods for schema generation. - Implemented JsonSchemaConverter abstract class to provide base functionality for specific type converters. - Refactored MethodDataConverter, SerializedMemberConverter, and SerializedMemberListConverter to inherit from JsonSchemaConverter. - Updated methods to utilize new schema generation logic, including GetSchema and GetSchemaRef. - Enhanced Reflector class to support schema generation for method parameters and return types with improved nullability handling. - Introduced defines parameter in schema generation methods to manage recursive type definitions and prevent infinite loops. - Improved error handling and documentation throughout the schema generation process.
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 38 out of 38 changed files in this pull request and generated 4 comments.
Comments suppressed due to low confidence (1)
ReflectorNet/src/Utils/Json/JsonSchema.cs:1
- The comment claims this prevents infinite recursion, but the actual check
defines.ContainsKey(defTypeId)at line 154 already handles this. The placeholder approach appears redundant. Consider simplifying by relying solely on theContainsKeycheck.
/*
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 38 out of 38 changed files in this pull request and generated 4 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Introduce support for complex types in JSON schema generation by implementing $defs handling and adding a 'result' property for return types. Update version to 2.1.1.