-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Upgrade json-schema to v6 #12348
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
Upgrade json-schema to v6 #12348
Conversation
composer.lockPackage changes
Settings · Docs · Powered by Private Packagist |
I've spent some time looking into the issue and did find some things:
Correct in version 5 there was a misinterpretation of what the
This is a difficult one apparently array support had found its way into the codebase. Object are more natural to JSON as the concept of an associative array only exists in PHP and not in JSON. This has side effects when casting object to array and vice-versa. It wasn't mentioned and therefor we are trying to fix (if possible) any issues with array data in version 6. But I'm also inclined to deprecate array data/schemas in version 6, removing it in version 7. So objects should be the way to go. I'm a bit busy at the moment so I'm afraid this might take so time to continue investigation. |
No rush at all, just wanted to get the ball rolling, and thanks for the context! |
$schemaData->required = []; | ||
} elseif ($schema === self::STRICT_SCHEMA && $isComposerSchemaFile) { | ||
if ($schema === self::STRICT_SCHEMA && $isComposerSchemaFile) { | ||
$schemaData = json_decode((string) file_get_contents($schemaFile)); |
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.
So getting rid of the $ref and instead loading the whole file in memory + adding the props below seems to work well.. Does anything speak against that do you think @DannyvdSluijs ?
Note that I tried to hack it with allOf but that didn't work as the branch of the allOf with the require failed saying name was required but also not defined, as it was defined only in the other branch. I guess this might be considered a bug but it's also a weird edge case.
The composer.lock diff comment has been updated to reflect new changes in this PR. |
The Symfony CI is broken when running on a 32bits PHP runtime with this change: https://github.com/symfony/symfony/actions/runs/14262540647/job/39977141591#step:5:23. I reported it at jsonrainbow/json-schema#816 |
Fixes #12345
cc @DannyvdSluijs there are still some issues I couldn't figure out, maybe you have a clue?
In JsonFile::validateJsonSchema it passes a validation request like this:
That used to work well, combining the schema file with some additional constraints about additional props and required props.. But not these seem to be ignored.
The other thing that seems to have broken from v5 to v6 is that we cannot pass arrays in anymore to be validated, it needs a
(object)
cast to work.. That seems harmless enough but was surprising as it's not mentioned anywhere.