jonasschmidt / ex_json_schema

An Elixir JSON Schema validator
MIT License
366 stars 98 forks source link

Support for multi-level dereferencing? #1

Closed nhuffman-brightcove closed 9 years ago

nhuffman-brightcove commented 9 years ago

ExJsonSchema.Schema.resolve/1 appears to support referencing separate schema files via $ref, e.g.

Load & resolve schema.json, which includes: "stuff": { "$ref": "sub-schema.json#/stuff" }

But doesn't seem to support multi-level references, e.g.

Where sub-schema.json referenced in schema.json includes: "morestuff": { "$ref": "sub-sub-schema.json#/morestuff" }

Any plans to include support for that?

jonasschmidt commented 9 years ago

Yes, that definitely sounds like something that should be supported. There's no test for "remote ref within remote ref" in the official test suite, so it's definitely not covered right now. References already work recursively though as there are tests for "ref within remote ref".

I might get a chance to look into it later today. Maybe it's a straight-forward fix :)

nhuffman-brightcove commented 9 years ago

Great! Yeah, at first glance, it looks like it's following the refs-within-refs, just not adding the sub-sub-schema to the end result.

jonasschmidt commented 9 years ago

Ok, it turned out to be a minor change. The recursive references were resolved but not added to the root schema's references dictionary. Fixed in 180fd319b90cffee9852d865dc5c989552837237 and https://hex.pm/packages/ex_json_schema/0.2.1 should be available through Hex.

jonasschmidt commented 9 years ago

Thanks for catching that issue.