Skip to content
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

Is there a way to get the ObjectSchema for a given location in the JSON? #93

Closed
ghost opened this issue Jul 15, 2017 · 3 comments
Closed

Comments

@ghost
Copy link

ghost commented Jul 15, 2017

The way the code works (as I see it), it works it's way in on the JSON being validated and the schema in tandem. So it dives in to a child property together and always has the JSON and schema paired.

I have a need outside that. I need to randomly get the type of a property in the JSON. So if I have the following JSON:

{"rectangle":{"a":-5,"b":"asd"}}

And I need to get the ObjectSchema for "a", is there a way in the existing library to basically say give me the ObjectSchema for "rectangle/a"?

If not, this is very easy to implement, I just don't want to duplicate existing code.

If I do need to write it myself, would you like the created method submitted as a pull request? And if so, any preference for the class it is in and/or the method name?

thanks - dave

@erosb
Copy link
Contributor

erosb commented Jul 16, 2017

Hello David,

Thank you for offering help with the development.

I'm not sure which version of the code you are looking at. The current git HEAD revision of the master branch heavily diverged from the source code of the latest release (174 commits added since version 1.5.1). These changes contain mostly 2 improvements

  • one is supporting the latest (draft 6) version of the json schema spec, which was published in April
  • the other one is tracking the location of sub-schemas and including them in the ValidationExceptions (and SchemaExceptions) - this is the information you need. So you can obtain this pointer using Schema#getSchemaLocation() if you use the HEAD revision.

I plan to publish a new release in the upcoming days, since yesterday I could make the library pass the draft v6 tests of the test suite. So if you can wait a few days then the best thing to do is probably waiting for the release. If need it more urgently, then you can start using the current HEAD.

@ghost
Copy link
Author

ghost commented Jul 17, 2017

I can definitely wait - well worth it. Please let me know when it's ready and which branch I should branch from then.

thanks - dave

@erosb
Copy link
Contributor

erosb commented Jul 21, 2017

Hello @DavidThi808 , I released the new version yesterday, it is available through JitPack, as described here .

Please let me know if you have any further questions.

@erosb erosb closed this as completed Jul 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant