Skip to content
This repository has been archived by the owner on Nov 8, 2024. It is now read-only.

Uses AJV for JSON Schema Draft V4 validation #404

Merged
merged 5 commits into from
Feb 4, 2020
Merged

Conversation

artem-zakharchenko
Copy link
Contributor

@artem-zakharchenko artem-zakharchenko commented Jan 16, 2020

Changes

  • Draft 4 is no longer considered legacy (in terms of which JSON Schema validator is being used)
  • Uses AJV to validate JSD4 instead of TV4
  • Preserves TV4 for implicit JSON Schema generation (from a body literal and headers)
  • Adjusts TV4 Schema Generator to be a valid representation of JSD4 (id -> $id)

Issues

@@ -1,5 +1,5 @@
const errors = require('../errors');
const { JsonSchemaLegacy } = require('./json-schema-legacy');
const { JsonSchemaValidator } = require('./json-schema-next');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since Header validation is based on an implicitly generated JSON Schema Draft 4, we cannot use the legacy class anymore. The legacy class is left only to support Draft 3.

@artem-zakharchenko
Copy link
Contributor Author

I'd like to merge this after Amanda is fully deprecated in #369. That way we could get rid of JsonSchemaLegacy class completely.

@artem-zakharchenko
Copy link
Contributor Author

I've added a regression test for JSON Schema Draft 4 usage of allOf and additionalProperties (originated in apiaryio/dredd#1647). Related to the changes since AJV is required to properly validated such situation for JSD4.

@artem-zakharchenko
Copy link
Contributor Author

I've postponed the introduction of the schemaPath property to errors[i].location. The reason is that it would require to be added to the spec explicitly (feature tests assert the exact shape of the location object). I have worries about this making location to exact in the spec, while it should be quite arbitrary by design. I think we don't have this properly introduced yet.

@artem-zakharchenko
Copy link
Contributor Author

Rebased upon the latest master to include the removal of Amanda.

  • Removed JsonSchema and JsonSchemaLegacy classes
  • Adjusted affected validators and tests

lib/validators/json-schema-next.js Outdated Show resolved Hide resolved
@artem-zakharchenko artem-zakharchenko merged commit 888b34d into master Feb 4, 2020
@artem-zakharchenko artem-zakharchenko deleted the ajv-draft-4 branch February 4, 2020 10:54
@ApiaryBot
Copy link
Collaborator

🎉 This PR is included in version 9.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants