-
Notifications
You must be signed in to change notification settings - Fork 2.4k
improvement: schema validation error quality, phase 2 #1985
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This was referenced Apr 12, 2019
Closed
Author
|
please build |
clarifies the schema and adds custom error messages for unclear error conditions
shockey
commented
Apr 17, 2019
shockey
commented
Apr 17, 2019
shockey
commented
Apr 17, 2019
shockey
commented
Apr 17, 2019
test/unit/plugins/json-schema-validator/test-documents/1672.yaml
Outdated
Show resolved
Hide resolved
shockey
commented
Apr 17, 2019
test/unit/plugins/json-schema-validator/test-documents/1853.yaml
Outdated
Show resolved
Hide resolved
shockey
commented
Apr 17, 2019
test/unit/plugins/json-schema-validator/test-documents/1711.yaml
Outdated
Show resolved
Hide resolved
shockey
commented
Apr 17, 2019
test/unit/plugins/json-schema-validator/test-documents/1711.yaml
Outdated
Show resolved
Hide resolved
…value this prevents false positives when the pivot key is missing entirely
Author
|
Fin |
17 tasks
shockey
added a commit
to shockey/swagger-editor
that referenced
this pull request
May 23, 2019
…i#1985) * adopt @webron's OpenAPI 3.0 schema from OAI/OpenAPI-Specification#1270 permalink: https://github.com/OAI/OpenAPI-Specification/blob/92e15eba1d4591ebfe8c11898c48241e72854381/schemas/v3.0/schema.yaml * add ajv-errors * address error messages for swagger-api#1808's Swagger 2.0 example clarifies the schema and adds custom error messages for unclear error conditions * address error messages for swagger-api#1808's OpenAPI 3.0 example * restrict underlying JSON Schema `type` field to simple types only (for swagger-api#1832) * fix limitation in JSON Pointer conversion helper * add clear `not` error message (for swagger-api#1489) * add additionalProperties message (for swagger-api#1394) * add ajv-keywords * use `switch` to intelligently identify inline vs referenced content (for swagger-api#1853) * use `switch` to XOR `schema` and `content` (for swagger-api#1853) * use `switch` to pivot security scheme based on type (for swagger-api#1672) * use switch to fall-through to inline security scheme validation (for swagger-api#1672) * rewrite more Reference oneOfs (for swagger-api#1519) * add custom message for `Schema.required` type error (for swagger-api#1519) * rewrite Response/Reference oneOf (for swagger-api#1489) * use switch in ParameterLocation validation (for swagger-api#1797) * define pivot key switches for SecurityDefinitions (for swagger-api#1711) * give helpful `format: uri` messages for SecurityDefinitions (for swagger-api#1711) * eliminate NonBodyParameter; pivot on `Parameter.in` with a switch (for swagger-api#1511) * oneOf -> switch for Parameters.items reference * (for swagger-api#1711) * remove redundant semantic validator (for swagger-api#1511) * adjust wording of custom error message (for swagger-api#1853) * add regression tests for all related issues * revert to expect@^1.20.2 * linter fixes * fix messaging flaw for swagger-api#1832 * improve messaging for swagger-api#1394 * use literal key for `$ref` in Reference Object * remove commented legacy data from OAS3 schema * remove superfluous quotation marks * normalize test case paths to `/` * normalize openapi fields to 3.0.0 * drop unused `paths` information * ensure clear errors for 3.0 Parameter style/content exclusivity * add `required` assertions to switch statements that pivot on a key's value this prevents false positives when the pivot key is missing entirely * remove stray space
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR is the second phase of my schema validation improvement work (phase 1 was introduced via #1982 and #1984).
It includes changes to the OpenAPI validation schema documents, our AJV instance, and one small modification to our local JSON Schema meta-document.
A few techniques have been deployed here:
oneOfto artificialswitchconstructs that pivot the validation schema based on specific keys$refproperty is presentNotably, this modifies generated errors to report their locations with JSON Pointer-compliant strings. Downstream consumers of schema errors may need to make changes accordingly, but this is not a breaking change since schema errors are within an internal subsystem.
Motivation and Context
Fixes #1853.
Fixes #1832.
Fixes #1808.
Fixes #1797.
Fixes #1711.
Fixes #1709.
Fixes #1672.
Fixes #1519.
Fixes #1511.
Fixes #1489.
Fixes #1480.
Fixes #1394.
How Has This Been Tested?
No tests for now - I may add tests for the linked issues before merging.
Checklist
My PR contains...
src/is unmodified: changes to documentation, CI, metadata, etc.)package.json)My changes...
Documentation
Automated tests