-
Notifications
You must be signed in to change notification settings - Fork 356
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
Testcase for minProperties with properties defined + Fix tests #406
Conversation
…nrainbow#362) * Add URI translation for retrieval & add local copies of spec schema * Use dist copies of schemas No need to keep duplicate files around in package://tests/fixtures/ if we're distributing them for users anyway. * Move package:// translation after all other rules Allows users to rewrite to package:// targets and still have the URI work.
* centralize errors * isolate 'more' info * throw exception for missing error message * swap args
This reverts commit 73ef463. 'email' is only a valid type attribute in draft-03 (later versions of the spec explicitly limit the value of type to the core primitive types), and this code doesn't validate email addresses anyway. IMO we should be validating it properly or not at all, and noting this went away after draft-03 my opinion is on the not-at-all side of the fence. Note that 'email' is *never* defined as a spec type, in any version - it just slips in under the radar of the draft-03 language which allows users to put arbitrary things in the type field.
…rainbow#376) (jsonrainbow#378) * Add provided schema under a dummy / internal URI (fixes jsonrainbow#376) In order to resolve internal $ref references within a user-provided schema, SchemaStorage needs to know about the schema. As user-supplied schemas do not have an associated URI, use a dummy / internal one instead. * Remove dangling use * Change URI to class constant on SchemaStorage
* add quiet option * use verbose instead of quiet * add quiet option * always output dump-schema * always output dump-schema-url * fix typo and ws
* Add test coverage for coercion API * Complete test coverage for SchemaStorage * Add test coverage for ObjectIterator * Add tests for ConstraintError * Add exception test for JsonPointer * MabeEnum\Enum appears to use singletons - add testing const * Don't check this line for coverage mbstring is on all test platforms, so this line will never be reached. * Add test for TypeConstraint::validateTypeNameWording() * Add test for exception on TypeConstraint::validateType() * PHPunit doesn't like an explanation with its @codeCoverageIgnore... * Add various tests for UriRetriever * Add tests for FileGetContents * Add tests for JsonSchema\Uri\Retrievers\Curl * Add missing bad-syntax test file * Restrict ignore to the exception line only * Fix exception scope
* Allow the schema to be an associative array Implements jsonrainbow#388. * Use json_decode(json_encode()) for array -> object cast * Skip exception check on PHP versions < 5.5.0 * Skip test on HHVM, as it's happy to encode resources
…nbow#359) (jsonrainbow#365) * Don't try to fetch files that don't exist Throws an exception when the ref can't be resolved to a useful file URI, rather than waiting for something further down the line to fail after the fact. * Refactor defaults code to use LooseTypeCheck where appropriate * Test for not treating non-containers like arrays * Update comments * Rename variable for clarity * Add CHECK_MODE_ONLY_REQUIRED_DEFAULTS If CHECK_MODE_ONLY_REQUIRED_DEFAULTS is set, then only apply defaults if they are marked as required. * Workaround for $this scope issue on PHP-5.3 * Fix infinite recursion via $ref when applying defaults * Add missing second test for array case * Add test for setting a default value for null * Also fix infinite recursion via $ref for array defaults * Move nested closure into separate method * $parentSchema will always be set when $name is, so don't check it * Handle nulls properly - fixes issue jsonrainbow#377
* Improve performance - don't loop over everything if already valid * Don't coerce already-valid types (fixes jsonrainbow#379) * Add remaining coercion cases & rewrite tests * Add all remaining coercion cases from ajv matrix * Rewrite the coercion tests to tidy things up a bit * Add CHECK_MODE_EARLY_COERCE If set, falls back to the old behavior of coercing to the first compatible type, regardless of whether another already-valid type might be available. * Add multiple-type test that requires coercion * \JSON_PRETTY_PRINT doesn't exist in PHP-5.3, so work around this * Various PR cleanup stuff * Fix whitespace * Turn $early into $extraFlags * Change "string" to "ABC" in string test * Update README.md description of CHECK_MODE_EARLY_COERCE * Move loop after complex tests definition * Move test jsonrainbow#39 to grid jsonrainbow#15
Thanks for catching this. What do you think is wrong with that line? I notice that this PR contains tests, but not a fix. Are you intending to fix this bug, or are you asking us to fix it, and contributing tests? |
@flolivaud is a co worker so I can give some more info. In https://github.com/justinrainbow/json-schema/blob/master/src/JsonSchema/Constraints/UndefinedConstraint.php#L66 I don't think It’s not a blocker for us so I don’t know when we’ll take a look at this, for the moment we're contributing tests. no rush to fix ☺ |
might be related to /fixed by #411 |
@mathroc #411 seems to fix it - these tests now pass :-). @flolivaud Could you please rebase this on 6.0.0-dev? |
@@ -72,7 +72,7 @@ public function getInvalidTests() | |||
return array( | |||
array( | |||
'{ | |||
"value": 1 |
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.
Why is this value being changed, rather than adding the new test independently?
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.
because this test was incorrect, the object was found invalid for the wrong reason (because value
was an integer instead of an object)
'{ | ||
"value": 1 |
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.
Why is this value being changed, rather than adding the new test independently?
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.
because this test was incorrect, the object was found invalid for the wrong reason (because value
was an integer instead of an object)
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.
both tests might be simplified by not having the value
wrapping but we chose not to change that to keep the diff simpler
Object validation attempts to use a single variable to store both the object definition, and its properties. This causes validation to be incomplete where "properties" is not set, but "additionalProperties" is. This commit fixes both bugs in issue jsonrainbow#353.
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.
LGTM. Thanks guys :-).
see #416 for 6.0.0-dev base |
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 PR is not OK. It now contains a zillion commits, some of which will break backwards-compatibility.
All that was needed was to change the base of the PR to merge into the 6.0.0-dev branch - that's what I meant when I asked you to rebase it on 6.0.0-dev. Sorry if I phrased this in a way that was unclear. There were no other changes needed here.
The master branch in this repo is frozen, pending merge of 6.0.0-dev into it. New commits do not go there; they will cause merge conflicts. New commits go into 6.0.0-dev, and ones that do not break backwards-compatibility get backported to the 5.x.x branch.
I can see you've opened a duplicate (#416) which looks exactly as this one would have looked after changing the base, so let's just go with that. This one can probably be closed as redundant.
close duplicate #416 |
@erayd how do you change the base of a PR ? |
@mathroc At the top-right of the PR, click the 'Edit' button. Then select the base branch that you wish to merge into from the dropdown menu just below the PR title. Then click 'Save'. |
The
minProperties
is not working ifproperties
is defined.It's probably because of https://github.com/justinrainbow/json-schema/blob/master/src/JsonSchema/Constraints/UndefinedConstraint.php#L66