-
Notifications
You must be signed in to change notification settings - Fork 162
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
Add rule to validate all schemas and examples in schemas #386
Comments
AJV validates JSON Schema. OAS 3.0 is not valid JSON Schema... consider some OpenAPI-specific features. OAS 3.0 is an extended subset of JSON Schema:
Maybe you should consider updating to OAS 3.1. |
Yes, i understand that, but how is that related to the problem and requested features? AJV extended with nullable support only helps to detect a problem with incompatibilities with OAS 3+.
Also don't understand how it helps here. How does this affect requested features? |
Oh, I see, nullable was removed in 3.1 and schema now is the superset of json schema 2020-12. There is still a problem with 3.0, but probably it can be ignored, as this is not actual for 3.1. Also the list of formats was shortened. But it's still will be useful to support common formats like date-time and uuid. And anyway, it will be useful to have all examples validation. |
Does the no-invalid-schema-examples help? I think we may have added this since you asked the question. |
Is your feature request related to a problem? Please describe.
I made an OpenAPI document, that passes validation, but is not fully conformant with OpenAPI. In the doc there was a schema like:
According to OpenAPI spec:
So as I understand,
nullable: true
makes sense only with explicittype
property in the same json-object.I discovered the problem, when tried to use for my api-spec openapi-request-validator, that uses ajv, that fails with the exception just like in #319 (
"nullable" cannot be used without "type"
).For now, there is built-in 'no-invalid-media-type-examples', that only validates examples in media type objects. ajv validator implementation will check the schema itself for correctness on construction and will detect problems with the schema (like
"nullable" cannot be used without "type"
). But:example
property in OpenAPI spec) will not be validated.format
is not considered during validation (tried withdate-time
, others probably ignored too).Describe the solution you'd like
It will be useful to have a built-in rule to validate all schemas itself. Or maybe all schemas should be validated by default regardless of any rules config.
Also it will be useful to have a rule to validate examples in all schemas (nested too).
And of course,
format
should be considered during examples validation (in 'no-invalid-media-type-examples' too).The text was updated successfully, but these errors were encountered: