-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Multiple schema versions #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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 integrates comprehensive multi‐version JSON Schema support using a new SchemaVersion enum and updates to core schema types and factory methods. Key changes include:
- Adding an optional SchemaVersion parameter to all schema constructors and factory conversion methods.
- Updating test cases and converters to validate and detect the correct schema version.
- Enhancing schema feature validations and ensuring version‐specific keyword generation.
Reviewed Changes
Copilot reviewed 40 out of 40 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
src/Enums/SchemaVersion.php | Introduced SchemaVersion enum with cases for Draft 07, Draft 2019-09, and Draft 2020-12. |
SchemaFactory.php | Updated static methods to accept and use an optional SchemaVersion parameter and default version management. |
Various Schema Types (e.g., StringSchema.php, ObjectSchema.php, etc.) | Modified constructors to pass SchemaVersion to parent and update toArray() logic accordingly. |
Converter classes (e.g., JsonConverter.php, EnumConverter.php) | Adjusted conversion logic to propagate SchemaVersion from input or default settings. |
Tests (e.g., VersionSupportTest.php, etc.) | Updated expectation checks for schema version in output and feature validation testing. |
Comments suppressed due to low confidence (2)
src/Converters/EnumConverter.php:45
- The EnumConverter now passes the SchemaVersion to the constructed schema. Verify that all enum-backed conversions consistently handle the version parameter, and add a comment documenting the supported backing types for clarity.
'int' => new IntegerSchema($enumName, $this->version),
tests/Unit/VersionSupportTest.php:19
- [nitpick] The tests correctly validate enum values and names. Consider adding brief comments in the tests to explain the significance of validating different versions, aiding future maintainers in understanding version-dependent behaviors.
expect(SchemaVersion::Draft_07->value)->toBe('http://json-schema.org/draft-07/schema#');
🎯 Add Multi-Version JSON Schema Support
This PR implements comprehensive support for multiple JSON Schema specification versions, allowing users to choose between Draft 7, Draft 2019-09, and Draft 2020-12.
🚀 Key Features
Multi-Version Schema Support
SchemaVersion
enum with support for:http://json-schema.org/draft-07/schema#
https://json-schema.org/draft/2019-09/schema
https://json-schema.org/draft/2020-12/schema
Feature-Based Version Validation
SchemaFeature
enum cataloging 35+ JSON Schema features across versionsFlexible API Design
JSON Schema Import/Export
JsonConverter
for parsing existing JSON Schema documents$schema
property🔧 Technical Implementation
Version-Aware Keywords
Schemas automatically use appropriate keywords for their target version:
definitions
$defs
Feature Validation System
toArray()
Advanced Features by Version
if
/then
/else
)deprecated
annotationminContains
/maxContains
unevaluatedProperties
dependentSchemas
duration
,uuid
)📝 Usage Examples
Basic Version Selection
Feature Validation
JSON Schema Import
🧪 Testing
🔄 Backward Compatibility