-
Notifications
You must be signed in to change notification settings - Fork 22
Conversation
@@ -7,6 +7,7 @@ class UnknownValidatorError extends Error {} | |||
class NotValidatableError extends Error {} | |||
class NotEnoughDataError extends Error {} | |||
class JsonSchemaNotValid extends Error {} | |||
class JsonSchemaNotSupported extends Error {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Explicit error type to use in unit tests instead of asserting an exact message.
fda7b4e
to
5e9f09e
Compare
}; | ||
|
||
class JsonSchemaLegacy extends JsonSchemaValidator { | ||
validateSchema() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overriding JsonSchemaValidator.validateSchema()
to use TV4 to validate both V3 and V4 (copying previous implementation, refactored).
} | ||
}; | ||
const { JsonSchemaLegacy } = require('./json-schema-legacy'); | ||
const { JsonSchemaValidator, getSchemaVersion } = require('./json-schema-next'); | ||
|
||
class JsonSchema { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A wrapping class to determine which actual validator class to use. A temporary wrapper until we deprecate Amanda and TV4. Overkill: determines a JSON Schema's version twice (once in the wrapper class, another time in the actual validator class).
5e9f09e
to
826fcb2
Compare
@kylef, please, do you mind giving my approach a look? I would like to verify my vision is optimal before I proceed. Also to make sure the valid/invalid schema versions I added are okay. Thanks. |
826fcb2
to
a2a5d4d
Compare
a2a5d4d
to
57f1b05
Compare
5db7fa4
to
e82a1e2
Compare
6ae63b6
to
f9f9357
Compare
I've removed
I will add a new test suite to cover that the newly added method converts Amanda/TV4/AJV result format to Gavel-compliant error format properly as the next step. |
message: 'Amanda error message' | ||
}, | ||
1: { | ||
property: ['friends[2]', 'online'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amanda produces prop[n]
property, which appears to be invalid JSON pointer.
I've refactored the coercing logic so it produces ['fiends', 2, 'online']
JSON pointer format.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be considered a breaking change, but it's rather a bug fix, because it fixes an unexpected property format. It's expected to be a list of stings, and it was resolved to a plain string sometimes.
5bc782e
to
af51c6f
Compare
af51c6f
to
9bccf12
Compare
@kylef, could you please take a look at this pull request? It should be ready. Thanks 😊 |
🎉 This PR is included in version 8.2.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Contains backward-compatible changes that enable JSON Schema Draft 6/7 support (pre-requisite for OpenAPI support in Dredd).
Changelog
errors[n].location.property
names consistent and validator-agnostic (property
is not always an array that points to the deeply nested property, i.e.['friends', 2, 'name']
)toGavelResults()
) and respective unit testsGitHub
Roadmap
$schema
version (first as V3, then as V4)$schema
property)JsonExample
class to implementJsonSchemaValidator
properlynew JsonSchema()
test/unit/validators/json-schema.test
amanda-to-gavel-shared
TextDiff
unit testsvalidate
integration tests