for-GET/jesse

jesse:load_schema/2 question

Closed this issue · 2 comments

I have my schemas in priv/schema which I am loading by

Path = code:application(foo) ++ "/schema",
jesse:load_schemas(Path, fun(D) -> jiffy:decode(D, [return_maps]) end).

Later, I want to reference these loaded schemas by the ids embedded in the schemas themselves, but it appears the only way they're stored is using absolute paths on my local disk.

Example:

{
  "$id": "http://example.com/schema/foo.json",
}

Later I want to

jesse:validate("http://example.com/schema/foo.json", InputJSON)

but of course it says there's no schema named that. It seems like jesse attempts to locate the id attribute in a schema - does it just ignore it?

f3c0 commented

I think jesse uses use "id" instead of "$id" for that

{
  "id": "http://example.com/schema/foo.json",
}

Yes, that's right. Thanks for the answer