Closed matt-allan closed 7 years ago
I would suggest splitting the package on the next major release. Having a package split in between major release seems odd to me. Other than that I'm okay with your arguments since it's basically the same reasoning I took for splitting the league/uri package.
This makes a lot of sense to me. Having a general purpose validator would be useful, imo. Just be careful to version things correctly so that no one ends up with a broken install. 👍
Thanks for the feedback 😄
I've gotten pretty far on the new package. It should be ready soon. Closing this in favor of #98.
Right now this package provides implementations for 3 different standards:
The JSON pointer implementation is around 50 LLOC so it's not a huge deal to leave in the library. I would rather use gamringer/JSONPointer but it's PHP 7 only.
JSON Reference
The JSON Reference code is not as simple. The code for dealing with JSON Reference is half the library at this point. The
Dereferencer
,LoaderManager
,Reference
, all the loaders, and half of the functions are all for dereferencing. I would like to add more functionality like bundling schemas, fully dereferencing, and caching. At that point there will be more JSON Reference code than JSON Schema code.I think splitting the JSON Reference code into it's own library is the best idea at this point. That will allow the JSON Reference library to develop at it's own pace while the validator can stabilize.
I've been using the dereferencing to work with swagger lately and it's pretty useful on it's own. I would also like trying to write a compiled validator and being able to re-use the dereferencer would be 👌 . If you look at other languages that have json ref libraries they are being used by lots of projects besides validators. As far as I know there is not an existing PHP library for resolving JSON Reference.
Separating Libraries
It should be pretty easy to separate the code into 2 libraries.
Right now the validator checks once if the schema is a reference because it's faster than using magic methods, but the validator doesn't even need to know about the dereferencing code. Since the reference object is a proxy the validator can just think it's using a regular JSON object.
I will need to do some benchmarking and see if a completely transparent proxy is fast enough. If it is the validator could drop the dereferencer as a dependency completely and just suggest it.
The pointer implementation is only used by the dereferencer, so splitting the libraries takes that code out of this project too.
I would like to do this before the next stable release. The next release is going to restructure a lot of the internals so I would prefer to do this at the same time.
The validator itself should be pretty stable at this point. Once the json ref code is removed, other than some minor changes to the validation errors the validator should be ready for 1.0.
Thoughts?