-
-
Notifications
You must be signed in to change notification settings - Fork 886
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 $dynamicAnchor and $recursiveAnchor in any schema location (not only root) #1745
Comments
I am sorry, I will not be able to investigate the problem with such a large schema / data sample. Please reduce it to a minimum size (definitely under 20 lines in the schema) when it still demonstrates the issue - either by removing all properties from the schema/data that are not causing issues (and any other parts of the schema) or by starting from scratch, trying to build the example that you think should work but doesn’t. |
I asked the OpenAPI folks for help and they provided a minimal reproduction: schema {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"schema": { "$dynamicRef": "#meta" }
},
"unevaluatedProperties": false,
"$defs": {
"schema": {
"$dynamicAnchor": "meta",
"type": ["object", "boolean"]
}
}
} instance {
"schema": { "type": "string" }
} According to them, this is a bug in AJV: "It appears that the |
Thanks, so it’s a duplicate of #1573 |
|
Hello @epoberezkin, do you have any insights about the progress of this issue? |
Is there any progress on that? |
It’s non-trivial, but maybe some time this year I will find a day… Happy to offer a bounty from Ajv open collective for thorough implementation of this thing - say $500-1000 - with tests, docs, etc. Let me know if you are interested. |
This might be a smaller effort than you think. Most implementers start off thinking it's hard, and then the actual implementation ends up being a very simple. Given how much of this feature ajv already supports, it's hard to imagine it would take much to get it over the finish line. I say this as someone who has implemented this feature and has discussed it's implementation with several other implementers, but I don't know this code base and what unique challenges it might face, so you experience may vary. I'm just sharing my experience in case it's helpful. |
You are probably right... |
Not sure I could help with my little knowledge of the issue... |
Any progress on this? Is the bounty offer still open? |
blocked-by: ajv-validator/ajv#1745 closes #200
What's the status on this? |
From what I can tell this is still the only holdup for |
I am going to take a look at this, but I have a lot of context to get up to speed with first. I assume it is still a desired fix :) |
What version of Ajv are you using? Does the issue happen if you use the latest version?
8.6.2, which should be the latest
Ajv options object
See OAI/OpenAPI-Specification#2489 for a discussion on the options.
JSON Schema
The OpenAPI 3.1 schema defined here: https://github.com/OAI/OpenAPI-Specification/blob/main/schemas/v3.1/schema.json
I'm not proficient enough to make this a minimal reproduction example.
Sample data
the OpenApi v3.1 webhook example here: https://github.com/OAI/OpenAPI-Specification/blob/main/examples/v3.1/webhook-example.json
Your code
See: https://runkit.com/essential-randomness/612d87df07ae0a00092a3492.
This simply call ajv with the given options, passes the OpenApiv3.1 schema and tries to validate the OpenApi Webhook example:
Validation result, data AFTER validation, error messages
What results did you expect? I would expect the validation to pass.
Are you going to resolve the issue?
I would like some help understanding whether the issue is in AJV or the OpenAPI specification. I was trying to add support for OpenAPIv3.1 to some JavaScript libraries that use AJV, but unfortunately this makes it impossible.
There's many libraries that will (hopefully) want to make this switch at some point, but I couldn't find anyone who has already done it or has published an investigation of what's needed to get this working. If anyone is ever going to fix it, understanding what's going on would be the first step :)
The text was updated successfully, but these errors were encountered: