brandur / json_schema

A JSON Schema V4 and Hyperschema V4 parser and validator.
MIT License
230 stars 45 forks source link

json_schema and json_pointer #28

Open okitan opened 9 years ago

okitan commented 9 years ago

json_schema and json-pointer cannot be used at the same time. That is because JsonPointer is module in json_schema but class in json-pointer.

[1] pry(main)> require "json-pointer"
=> true
[2] pry(main)> require "json_schema"
TypeError: JsonPointer is not a module

This kind of conflict is really difficult to solve, when I'd like to use two libraries and one uses json_schema and the other uses json-pointer.

I think the easiest workaround (but ugly) of it is to change JsonPointer in json_schema from module to class. It is really lucky JsonPointer in json_shema does not have JsonPointer.evaluate and JsonPointer::Evaluator...

What do you think about this issue?

brandur commented 8 years ago

Oof, this is a tricky one.

I think I ended up exposing JsonPointer from the package because I'd thought about splitting it out into its own package eventually (outside of json_schema). Looking back on it now though, it's really not right that json_schema brings things in that are not scoped to its local namespace. JsonPointer here should probably be JsonSchema::JsonPointer to be representative of the fact that it comes from this package.

That said, given that this is technically a breaking API change, I'd probably want to increment the major version to wrap all of this up.

Would this approach solve your problem?