-
-
Notifications
You must be signed in to change notification settings - Fork 76
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
Validation fails for schemas when used in mixed API context #348
Comments
There were couple approaches considered as a fix:
1st approach pros/conspros:
cons:
2nd approach pros/conspros:
cons:
Given that the con from 2nd approach only happens 1 time a year (during new version release) and is pretty straight forward search/replace will go down this path. Also, there's possibility to automate this with a script if it's ever painful! IMO, keeping friendly, no "hidden tricks" package api and less changes in Ghost core far outweighs small maintenance burden. |
Considerations around prefix or postfix naming changeThere's not much difference in either approach. The only reason going with postfix notation |
For reference "$id" property naming conventions for JSON Schema - https://json-schema.org/understanding-json-schema/structuring.html#the-id-property. There is no specific convention enforced except:
And it's primary goal is:
|
closes TryGhost#348 - $id property is meant to be a unique identifier: "It declares a unique identifier for the schema." (ref. https://json-schema.org/understanding-json-schema/structuring.html#the-id-property) - Previously uniqueness was kept only per folder "version" (v2/canary) but as validator is meant to be used across versions that uniqueness is no longer enough - The $id clash was effecting schema caching inside ajv. Having unique $id fixes the clash
closes #348 - $id property is meant to be a unique identifier: "It declares a unique identifier for the schema." (ref. https://json-schema.org/understanding-json-schema/structuring.html#the-id-property) - Previously uniqueness was kept only per folder "version" (v2/canary) but as validator is meant to be used across versions that uniqueness is no longer enough - The $id clash was effecting schema caching inside ajv. Having unique $id fixes the clash
refs TryGhost/SDK#348 - There was an issue with schema clashing in the cach that caused validation to be run agains wrong API version
refs TryGhost/SDK#348 - There was an issue with schema clashing in the cach that caused validation to be run agains wrong API version
Issue Summary
Data validation cashes schema definition from single API which leads to incorrect validation results. In other words, valid data for v3 API is getting validated against v2 schema.
To Reproduce
post
resource data againstv2
schemaposts
which is only valid in v3 API (add email_subject field)email_subject
is a valid field for canary/v3 schemas.Expected behavior is - validation should always match schema definition and not throw errors for valid data.
The cause for a bug is schema caching which done on validator/ajv level.
Technical details:
The text was updated successfully, but these errors were encountered: