-
-
Notifications
You must be signed in to change notification settings - Fork 921
Additional properties: false to allow better type checking from JSON schemas #3388
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
Additional properties: false to allow better type checking from JSON schemas #3388
Conversation
You should fix the CS too 🙂 |
Done! I was double checking the failing tests as well but it seems unrelated. |
Let's wait for #3402 first, as it'll make use of |
@teohhanhui is there anything I can do to speed up the merging process? Having this change merged and released would highly reduce the bug risks in my production-deployed TypeScript consumers. |
@quentinus95 we need to progress at our own pace :|. You should be able to use your fork (and this patch) by tweaking the |
@soyuka sure! It was just to be 100% sure nothing more was required on my side. |
@teohhanhui any feedback now that #3402 has been merged? |
could you rebase? thanks! |
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.
Sorry for the late review...
Can you also rebase please?
@@ -110,6 +110,7 @@ public function buildSchema(string $className, string $format = 'json', string $ | |||
} | |||
|
|||
$definition = new \ArrayObject(['type' => 'object']); | |||
$definition['additionalProperties'] = false; |
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.
We should set this flag only if the allow_extra_attributes
normalization context option is set to false
: #1217
Thanks @quentinus95 ! Superseeded by #3804 |
This change sets additional properties to false on all definitions so developers using code generators (e.g. TypeScript code generators from JSON schema) can have safer type checks.