-
Notifications
You must be signed in to change notification settings - Fork 393
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
Support prefixItems
for tuple validation
#543
Comments
This is a pretty unfortunate change in the spec. It means that the meaning of A middle of the road approach to support this without breaking others' code may be to expose the new behavior behind a switch, say Want to give this a shot? |
added `--usePrefixItems` cli argument. When passed, JSON schemata containing `prefixItems` tuple validation key will parsed correctly.
Function isArrayType() should return true when `prefixItems` is present, even without `items` key
Added `usePrefixItems` option, which defaults to false
Created new test case
I thought I'd have a go at it. Added a CLI argument as "--usePrefixItems" which defaults to false, I did not think specifying JSON schema spec version would be helpful at this point since only this version would be supported. The main addition is a new normalizer rule; renaming the schema keys. schema.additionalItems = schema.items
schema.items = schema.prefixItems
delete schema.prefixItems I created a simple unit test as well. I will let it sink in cause maybe more test cases might be needed. I had difficulty understanding the E2E testing setup, so I did not add any new E2E tests, maybe if somebody would very briefly walk me through I am going to do so. Tests are passing, for now. |
Any news on this topic? |
From the JSON Schema 2020-12 Release Notes:
For an example with more explanation:
https://json-schema.org/understanding-json-schema/reference/array.html#tuple-validation
As per #1 (which has a broken link by the way), here is the respective file from the official test suite:
https://github.com/json-schema-org/JSON-Schema-Test-Suite/blob/main/tests/draft2020-12/prefixItems.json
In case there is interest in resolving this issue, I would be willing to look into the code (I've already checked the relevant parts of parsing and generation) and try to provide a pull request for it.
The text was updated successfully, but these errors were encountered: