npoint icon indicating copy to clipboard operation
npoint copied to clipboard

$ref schemas are cached and do not update

Open azirbel opened this issue 5 years ago • 0 comments

It's possible to set a schema to reference another JSON document. For example:

{
  "$ref": "https://api.npoint.io/XYZ"
}

You might want this if you have saved several documents in npoint, and want them all to share the same schema.

However, if you do this, then update the referenced schema at XYZ, it will not work. The old schema saved at XYZ is cached, and the cached version will be used for validation.

I think this is happening because the json-schema library caches external URL loads by default.

We call that from e.g here: https://github.com/azirbel/npoint/blob/dc5ddef55099978af861ee361a5835065b6d8350/app/controllers/schema_controller.rb#L6

The library cache_schemas setting seems to be here: https://github.com/ruby-json-schema/json-schema/blob/ab1253a874f05a811fdb3280ca1f77ebc9af2902/lib/json-schema/validator.rb#L21

It looks like we simply need to set cache_schemas to true.

azirbel avatar Nov 27 '19 05:11 azirbel