-
Notifications
You must be signed in to change notification settings - Fork 356
Fix issues #32 and #33. Draft v3 compliance excluding $ref, $schema, and id. #41
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
Thanks for the PR - especially with the new tests! |
You're welcome! Thanks for merging. Note that most, if not all, of the new tests that I added came from JSON-Schema-Test-Suite. By merging #41 your json-schema project now supports all of draft-03, except for $ref, $schema, and id. |
This was referenced May 28, 2013
mchiocca
referenced
this pull request
in mchiocca/json-schema
May 30, 2013
hakre
pushed a commit
to hakre/json-schema
that referenced
this pull request
Mar 26, 2015
Fix issues jsonrainbow#32 and jsonrainbow#33. Draft v3 compliance excluding $ref, $schema, and id.
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.
These changes include a number of fixes for some bugs that were identified by tests that are part of a draft v3 test suite. For example.
preg_match()
.A number of new unit tests from a draft v3 test suite were added to verify the correctness of the updated new functionality.
Also included with these changes is a fix for issue #32, required properties ignored. The
required
attribute works in two ways. For example.So
required
is now supported both as an attribute assigned to an individual property, or as an array of properties that's part of the schema definition. The former is draft v3 compliant while the latter is draft v4.Various issues with
array
types, including the use ofitems
andadditionalItems
were also resolved. Validates correctly againstitems
when it is a schema, or an array of schemas (tuple typing).Problems with the use of
additionalItems
have been fixed.Unit tests in ArraysTest.php and TupleTypingTest.php have been updated to properly reflect draft v3 and v4. Existing tests have been fixed and updated with new tests added.
Notably, the use of the
required
attribute when specifyingitems
in the unit tests was erroneous. For example.The
required
attribute is ignored by both draft v3 and v4 implementations. Also, in draft v4, therequired
value is expected to be an array, not a boolean. The attribute has been removed from the unit tests.Also fixed in the unit tests was the use of
additionalProperties
whereadditionalItems
should have been used instead. Overall code coverage of Constraints/Collection.php has been improved.Also included in these changes is a fix for issue #33. Loose type checking for
integer
andnumber
basic types allowed JSON values that were invalid according to the JSON schema specification.For example, a string, such as "1" was considered a valid "integer". Also considered valid as a
number
were strings such as "1.5", etc. Strings are no longer considered validinteger
ornumber
types.The unit test file,
PhpTypeCastModeTest.php
, contained erroneous tests that accepted strings as valid forinteger
andnumber
types. The file has been deleted since the test cases were invalid.Changes also include the implementation of
exclusiveMinimum
andexclusiveMaximum
per draft specification. These keywords are now recognized and can be used withminimum
andmaximum
.New unit tests have been adapted from a draft v3 test suite to test and verify the use of
exclusiveMinimum
andexclusiveMaximum
. Theminimum
andmaximum
keywords continue to work as before.Support for
dependencies
has been implemented as per the draft v3 and v4 specifications. Thedependencies
property can be specified in any one of three ways.The first is according to draft v3. Draft v4 does not allow just an ordinary string. An array of strings, such as the second method, is according to draft v4. Both drafts support the third method, which is a schema.
The implementation of the
extends
attribute has been fixed. Now,extends
also accepts an array of schemas in addition to a string or a single schema. For example.When an array of schemas is specified, each schema in the array will be checked in addition to the base schema. The implementation of
extends
as a string remains the same.In total, the commits included in this pull request implement full draft v3 compliance with the exception of
$ref
,$schema
, andid
. All other features of draft v3 are fully implemented and pass draft v3 unit testing.The
RefResolver
partially implements support for$ref
. The current implementation of$ref
doesn't fully comply with draft v3 and does not pass draft v3 unit testing.