Skip to content

Fix #93 ($ref to local definition not working) #182

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
merged 3 commits into from
Sep 8, 2015

Conversation

araines
Copy link

@araines araines commented Aug 15, 2015

Another attempt at getting issue #93 sorted - thanks to @co3k and @stoiev for putting in the initial leg work. Based my initial work on #119, but actually got the tests running properly with the resolver too and the official test pack. This reduces the 8 failures mentioned by @bighappyface in #119 down to 3.

I'm not sure this is quite the right way to fix it from an architectural point of view, but it does improve the capability of this library, at least.

In order to get the remaining 3 failing tests to pass, I suspect there will need to be a fairly big rewrite. The main problem is around that of recursion - self-referencing documents will simply cause the current design to fail. But that should be the subject of another issue.

@bighappyface
Copy link
Collaborator

+1

This is the best start to resolving this (pun intended).

@araines thanks a ton for using the standard test suite and getting this most of the way there. With the high demand for this support, I think it is good to move forward.

@alecsammon @localheinz @GrahamCampbell would you please review?

@graste
Copy link

graste commented Sep 2, 2015

It would be really nice to have this working.

@bighappyface
Copy link
Collaborator

@graste may I have your help with code review? I prefer two peer reviews prior to merging a PR.

@graste
Copy link

graste commented Sep 3, 2015

Okay, I checked out master and applied this PR. It brings down the draft4 ref test failures from 8 to 3 as advertised. What I noticed is, that issue #93 is working fine even without this PR – see this gist. After having a look at the code I must say, that I've got the same feeling as @araines has with his PR: The solution might not be ideal as it feels a bit like not reusing stuff like UriRetriever::resolvePointer – otoh it brings down the failing tests. My suggestion to you would be to decide whether it's worth the improvements and temporarily include it or take the time to refactor the whole definitions and $ref related stuff. Short term including the PR would probably be okay, long term you need a bit of thinking/refactoring to handle the skipped tests from the json schema suite anyways.

What I noticed though when testing a $ref use case is, that the oneOf doesn't handle objects with different content correctly. I'll create a short PR (#187) with succeeding and failing test to show that.

@bighappyface
Copy link
Collaborator

@graste thanks for the review. I am merging and rolling v1.4.5

bighappyface added a commit that referenced this pull request Sep 8, 2015
Fix #93 ($ref to local definition not working)
@bighappyface bighappyface merged commit a4bee9f into jsonrainbow:master Sep 8, 2015
$validator = new Validator($checkMode);

$validator->check(json_decode($input), json_decode($schema));
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a clear sympton of BC Break

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't follow. Are you referring to the addition of RefResolver in the lines above or this specific line?

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

Successfully merging this pull request may close these issues.

4 participants