cvent / json-schema-deref-sync

Synchronous json schema dereference utility
http://bojand.github.io/json-schema-deref-sync
MIT License
35 stars 24 forks source link

Correctly dereference paths containing '.' #21

Closed pimterry closed 5 years ago

pimterry commented 5 years ago

This PR fixes #20.

mpath uses . to describe paths, so a.b.c is property a, then property b, then property c. Unfortunately, that makes it impossible to use keys that contain a ., even though that's legal JSON and appears in some schemas (in my case, Stripe's OpenAPI spec).

This PR drops the mpath dependency entirely, and replaces it by splitting the key on /, and stepping into the schema key by key. I also filter empty keys out, which neatly gets rid of both the / special case and the empty string special case.

I've also added a quick test covering this. That failed before, and now passes (along with all the others).

bojand commented 5 years ago

Hello, thanks for the PR. Merged and published as 0.9.0. Somehow there was a 0.8.0 already published even though the code was at 0.7.0, perhaps I double published something by mistake before. Thanks again.