-
-
Notifications
You must be signed in to change notification settings - Fork 877
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
compileAsync does not loadSchema a schema that is $ref’d by a oneOf with a discriminator #2427
Closed
yonran opened this issue
May 7, 2024
· 3 comments
· Fixed by so5/rwatchd#4, cdimascio/express-openapi-validator#938, Enterprise-CMCS/cmcs-eregulations#1361, kids-first/kf-api-arranger#168 or Ramyromel/chains#1
Closed
compileAsync does not loadSchema a schema that is $ref’d by a oneOf with a discriminator #2427
yonran opened this issue
May 7, 2024
· 3 comments
· Fixed by so5/rwatchd#4, cdimascio/express-openapi-validator#938, Enterprise-CMCS/cmcs-eregulations#1361, kids-first/kf-api-arranger#168 or Ramyromel/chains#1
Labels
Comments
Hi @yonran thanks for raising this, I have setup your example and it does look like it could be a bug. Since you responded "Maybe if it is easy" I'll ask if you would like to have a go at submitting a PR? Either way I will look into this and consider it a bug for now. |
yonran
added a commit
to yonran/ajv
that referenced
this issue
May 10, 2024
Make the discriminator code generation throw MissingRefError when the $ref does not synchronously resolve so that compileAsync can loadSchema and retry.
jasoniangreen
pushed a commit
that referenced
this issue
May 12, 2024
Make the discriminator code generation throw MissingRefError when the $ref does not synchronously resolve so that compileAsync can loadSchema and retry.
lib/commands/query.js |
`` |
This was referenced Jun 16, 2024
This was referenced Jun 24, 2024
This was referenced Sep 12, 2024
This was referenced Sep 14, 2024
This was referenced Sep 17, 2024
This was referenced Sep 19, 2024
This was referenced Sep 21, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What version of Ajv are you using? Does the issue happen if you use the latest version?
latest (8.13.0)
Ajv options object
JSON Schema
Sample data
Your code
Validation result, data AFTER validation, error messages
What results did you expect?
No error
Are you going to resolve the issue?
Maybe if it is easy
Notes:
If you call
ajv.addSchema
(i.e., uncomment the commented code), then the error goes away. Therefore, it is the resolving of the$ref
that is the issueWhen
discriminator: true
, thenloadSchema
is not called.But if you set
discriminator: false
and remove thediscriminator
fromschema.main
, thenloadSchema
is called.My guess is that lib/vocabularies/discriminator/index.ts’s
getMapping()
needs tothrow new MissingRefError
so that _compileAsync can catch the error and load the missing schemas.The text was updated successfully, but these errors were encountered: