OpenAPI 3.1 examples not validating through AJV using OpenAPI 3.1 spec
See original GitHub issueHello, there is a lot of JavaScript tooling that uses AJV to validate OpenAPI specs. None of it seems to support 3.1, which is really unfortunate. I was trying to remedy the situation, but failed miserably.
As far as I can tell (see https://github.com/ajv-validator/ajv/issues/1745) even the examples in your OpenAPI3.1 folder do not pass validation. The AJV folks (understandably) won’t help unless I create a minimal reproducible example of a failing schema, which I’m not really qualified to do.
Would you be able to help/shed light on what’s going on?
Copying the relevant details:
Ajv options object
{
allErrors: true,
validateFormats: false,
strictSchema: false,
strictTypes: false
}
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
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
Error message:
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
Thank you! Hopefully the errors are more understandable if you can read schemas 😃
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:14 (6 by maintainers)
Top GitHub Comments
any updates?
@no-identd Upgrading AJV won’t fix this problem until AJV fixes the bug responsible for the problem.