You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi folks,
I want to clearly address in which subschema the problem is(e.g. by $id)?
I setup the loadSchema callback and the schema are inserted in the ajv instance if everything is fine.
If the subschema has an error - e.g. simple type: "x" - the compileAsync rejects as expected.
But the error message and ajv.errors content are scoped to the subschema 'schema is invalid: data/type must be equal to one of the allowed values, data/type must be array, data/type must match a schema in anyOf'
So the paths are all wrong - here `/type' instead of '/root/property/type' if root.property.$ref = subschema. Having the correct paths would also be helpful but a promise reject is fine but then besides the ajv.errors I would expect a scope property or something like that.
Asynchronous version of compile method that loads missing remote schemas using asynchronous function in options.loadSchema. This function returns a Promise that resolves to a validation function. An optional callback passed to compileAsync will be called with 2 parameters: error (or null) and validating function. The returned promise will reject (and the callback will be called with an error) when:
missing schema can't be loaded (loadSchema returns a Promise that rejects).
a schema containing a missing reference is loaded, but the reference cannot be resolved.
schema (or some loaded/referenced schema) is invalid.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi folks,
I want to clearly address in which subschema the problem is(e.g. by $id)?
I setup the loadSchema callback and the schema are inserted in the ajv instance if everything is fine.
If the subschema has an error - e.g. simple
type: "x"
- the compileAsync rejects as expected.But the error message and ajv.errors content are scoped to the subschema
'schema is invalid: data/type must be equal to one of the allowed values, data/type must be array, data/type must match a schema in anyOf'
So the
path
s are all wrong - here `/type' instead of '/root/property/type' if root.property.$ref = subschema. Having the correct paths would also be helpful but a promise reject is fine but then besides the ajv.errors I would expect a scope property or something like that.But docs https://ajv.js.org/api.html#ajv-compileasync-schema-object-meta-boolean-promise-function is mentioning another callback but I cannot find it. If this callback would have the $id and the scoped messages from above then this would be even better.
Any hints to narrow down the problematic schema?
Beta Was this translation helpful? Give feedback.
All reactions