-
-
Notifications
You must be signed in to change notification settings - Fork 872
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
Discrepancy in addUsedSchema
between v6 and v8
#1558
Comments
addUsedSchema
between v6 and v8addUsedSchema
between v6 and v8
This is related to #1413 If you are combining the schemas as JS objects, the workaround is to not use $id's in inlined schemas: https://runkit.com/esp/6083d2fc1c64c9001adf7219 If $id is needed you need to use $refs currently. |
I see that now the schema is used as a key in a cache. In function addRef(this: Ajv, ref: string): string {
ref = normalizeId(baseId ? URI.resolve(baseId, ref) : ref)
if (this.opts.addUsedSchema === false) return ref // skip adding schema reference
if (schemaRefs.has(ref)) throw ambiguos(ref)
schemaRefs.add(ref)
.... Would this harm something? |
It is definitely worth trying - probably won't break anything. If all the tests pass, I am ok to release it as the only change (which means not the next release) and see if anything breaks, in which case I can revert... |
Hello @epoberezkin @misozask , I would like to take this up. |
I have raised the PR here #2336, would appreciate the review. |
What version of Ajv are you using? Does the issue happen if you use the latest version?
Migrating from 6.11 to 8.1
Ajv options object
{allErrors: false, addUsedSchema: true/false}
Code
What results did you expect?
The above code works without issues in v6.
The
combined
schema will be compiled, and both schemas will be either cached or not( depending onaddUsedSchema
)However in v8.1 the compilation fails with message
Error: reference "hex" resolves to more than one schema
Thats might be acceptable for
addUsedSchema: true
, but forfalse
I would expect to compile thecombined
schema.Is this intended behavior? I would appreciate to not fail with
addUsedSchema: false
option, similar as in v6.(BTW: I'm aware of $ref, I just find easier to work and define JSON schemas as plain JS objects and referencing them as objects )
The text was updated successfully, but these errors were encountered: