You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Refactoring of the JSON Schema code to enhance clarity and maintainability. (#450)
This update focuses on several key areas within the JSON Schema processing code:
1. **Improved Readability in `JsonSchema.kt`**:
* I've broken down the `resolveDefinition` method into smaller, private helper functions (`resolveLocalDefinition`, `findDefinitionInMaps`, `findPropertyRecursive`). This makes the code easier to follow and understand.
* The `allDefinitions` property now uses a more concise functional expression: `definitions + (defs ?: emptyMap())`.
2. **Enhanced Clarity in `JsonObjectDef.kt` and `PropertyDef.kt`**:
* I've added comprehensive KDoc comments to public and protected classes, methods, and properties in `JsonSchema.kt`, `JsonObjectDef.kt`, and `PropertyDef.kt`. These comments explain parameters, return values, and the purpose of each component.
* I've clarified the expected types for the `type` property in `JsonObjectDef.kt` (String or List of Strings) with a comment, while keeping its declared type as `Any?` for Gson compatibility.
3. **Addressed TODOs and Code Style**:
* I moved the `JSON_SCHEMA_FORMAT_MAPPINGS` map from its own file into `ConfigManager.kt`, as suggested by an existing TODO comment.
* I've updated all usages of `JSON_SCHEMA_FORMAT_MAPPINGS` to reflect its new location in `ConfigManager`.
* The now-empty `JSON_SCHEMA_FORMAT_MAPPINGS.kt` file has been removed.
* I've ensured consistent code style and formatting across all modified files.
All existing unit tests pass, confirming that these changes have not introduced any regressions.
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
0 commit comments