jsonschema-rs icon indicating copy to clipboard operation
jsonschema-rs copied to clipboard

How to use custom resolvers in python?

Open karolzlot opened this issue 2 years ago • 2 comments

I have JSON schema splitted to more than one file (with refs) in local filesystem.

I use in python: jsonschema_rs.JSONSchema.from_str and then validate.

Result:

failed to resolve json-schema:///myschema.schema.json: cannot resolve relative external schema without root schema ID

It isn't surprising because jsonschema_rs isn't aware where to look for this external reference.

Is it possible to use custom resolver when using jsonschema_rs from python?

karolzlot avatar May 17 '22 12:05 karolzlot

When I specify path in "$id": in root schema, then I get different error:

relative URL without a base

It seems it can work only with URLs, not paths.

karolzlot avatar May 17 '22 12:05 karolzlot

Thanks for opening this!

Is it possible to use https://github.com/Stranger6667/jsonschema-rs/pull/341 when using jsonschema_rs from python?

Not at the moment, but it should be possible to implement on the bindings level. However, I am reworking this part now, so the interface might change, but it should not be much problematic to adjust it in the future.

When I specify path in "$id": in root schema, then I get different error: It seems it can work only with URLs, not paths.

Strange, I got to check why it is happening.

Stranger6667 avatar May 22 '22 19:05 Stranger6667