question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support $dynamicAnchor and $recursiveAnchor in any schema location (not only root)

See original GitHub issue

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

{
    allErrors: true, 
    validateFormats: false, 
    strictSchema: false, 
    strictTypes: false
}

See https://github.com/OAI/OpenAPI-Specification/pull/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

Invalid: 
data/webhooks/newPet/post/requestBody/content/application~1json/schema must NOT have unevaluated properties, 
data/webhooks/newPet/post/requestBody must match "else" schema,
data/webhooks/newPet must match "else" schema, 
data/components/schemas/Pet must NOT have unevaluated properties, 
data/components/schemas/Pet must NOT have unevaluated properties

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 😃

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

5reactions
OlivierCuypcommented, Nov 19, 2022

Not sure I could help with my little knowledge of the issue… I just wanted to mark my interest on this issue. It would be so great to have OpenApi 3.1.0 validation.

0reactions
epoberezkincommented, Nov 15, 2022

You are probably right…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Support $dynamicAnchor and $recursiveAnchor in any schema ...
Support $dynamicAnchor and $recursiveAnchor in any schema location (not only root)
Read more >
Combining schemas - Ajv JSON schema validator
Now to compile your schema you can either pass all schemas to Ajv instance: ... $recursiveAnchor / $dynamicAnchor can only be used in...
Read more >
Explanation of $dynamicRef $dynamicAnchor in Json Schema ...
A dynamic reference is used when an extending schema might need to ... But, the maxItems constraint will only apply to the root...
Read more >
Recursive Anchor - Liquid Technologies
A recursive schema is one that has a reference to its own root, identified by the empty fragment URI reference ("#"). Simply stated,...
Read more >
@hyperjump/json-schema-core - npm package | Snyk
All security vulnerabilities belong to production dependencies of direct and indirect packages. License: MIT. Security Policy: No.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found