santhosh-tekuri/jsonschema

Schema Stack is Private in Extension Compiler

theory opened this issue · 6 comments

In the extension compiler, I'd like to extract a path to the extension keyword in a particular schema. I think this could be achieved by accessing the schema stack in the CompilerContext, but the stack there is private. Is there some other method I'm missing? If not, would you be open to a PR to make it public or available via some other interface?

the schema stack in CompilerConetxt is implementation detail and may change in future, so it is not wise to access it.

what kind of extension you are trying to implement ?
may be i can help if i know the details...

The extension identifies properties that should be indexed. In my app, I'd like to get the full path to each property so I can extract it via a JSONPath query to index. So once I've compiled a schema, I'd like to get those paths from the schema (and any of its sub-schemas).

from your comment, it looks like your extension is similar to keyword required.

also i notice that, you are trying to use jsonschema as a configuration file containing the properties to be indexed. the validator is not meant for this purpose. i.e you are trying to extract some information from schema and trying to use it post-validation.

i suggest to rethink your usecase.

also i think what you need is the instance-location not schema-location. can you provide sample examples demonstrating your extension usage.

It's both instance-location and schema-location:

  1. When the schema is compiled, I want to look at it to see which paths are defined to be indexed, so I can create the necessary indexes.
  2. After the schema has validated a JSON object, I want to use the data from the schema to pull out the values to include in the index when I add it to the database.

So yes, I want to have the information necessary from the schema, and will use it after validation, but the validator will be unaffected.

I am not convinced of your use case.

I feel it is not appropriate to expose these internals. I suggest to clone this project and modify as per your requirements.

Will do, see what I figure out, may come back with a PR or two. Thanks