Extend Property struct to support examples and handle complex additionalProperties#37
Merged
Extend Property struct to support examples and handle complex additionalProperties#37
Property struct to support examples and handle complex additionalProperties#37Conversation
Initializes the examples field as an empty vector when converting Attribute to schema::Property. This prepares the Property struct for future use of example values.
Added custom deserializer to support 'additionalProperties' as an object in SchemaObject. Updated tests to cover this case and added support for 'examples' in Property struct.
Introduces support for validating JSON schema files in the CLI by checking the input type and delegating to a new validate_from_json_schema function. Handles validation errors and logs results appropriately.
There was a problem hiding this comment.
Pull Request Overview
This PR enhances JSON Schema handling by adding support for examples in properties and improving additionalProperties compatibility. The changes ensure schemas with object-valued additionalProperties are correctly interpreted and allow serialization of property examples.
- Added custom deserialization for
additionalPropertiesto handle both boolean and object forms - Extended
Propertystruct with anexamplesfield for serialization support - Added test coverage for object-valued
additionalPropertiesscenarios
Reviewed Changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/json/schema.rs | Added custom deserializer for additionalProperties and examples field to Property struct |
| src/json/import.rs | Added unit test to verify handling of object-valued additionalProperties |
| src/json/export.rs | Initialize examples field when converting Attribute to Property |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Added a custom deserializer for the SchemaObject title field to strip all whitespace characters during deserialization. Includes tests to verify whitespace removal for various input cases.
Logende
approved these changes
Sep 24, 2025
Updated the Property struct so that the examples field is now a Vec<Value> instead of Vec<String>, allowing for more flexible example types in JSON schema properties.
Updated version numbers to 0.2.7 in Cargo.toml, Cargo.lock, and pyproject.toml for the mdmodels and mdmodels_core projects.
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.
This pull request introduces improvements to the handling of JSON Schema objects in the codebase, specifically around the
additionalPropertiesfield and the support forexamplesin properties. The changes enhance compatibility with schemas that use objects foradditionalPropertiesand allow serialization of property examples.Schema compatibility and serialization improvements:
src/json/schema.rsto support both boolean and object forms of theadditionalPropertiesfield, ensuring that schemas with object values are correctly interpreted as allowing additional properties.SchemaObjectstruct to use the new deserialization logic foradditionalProperties, improving schema import robustness.src/json/import.rsto verify correct handling of object-valuedadditionalProperties, increasing test coverage for schema import scenarios.Property serialization enhancements:
examplesfield to thePropertystruct insrc/json/schema.rs, allowing property examples to be serialized if present.examplesfield is initialized to an empty vector when converting anAttributeto aPropertyinsrc/json/export.rs, maintaining consistency in property serialization.