transmute-industries / verifiable-credentials

v2
https://github.com/transmute-industries/verifiable-credentials
Apache License 2.0
9 stars 1 forks source link

Add Support for Resolving External JSON Schemas #12

Open tsnyder-gs1us opened 2 weeks ago

tsnyder-gs1us commented 2 weeks ago

We were exploring the visibility of creating a shared GS1 Schema definition instead of copying the same attributes into multiple files. For example, multiple GS1 Credentials have the same organization attributes. Instead of copying these into each JSON Schema we wanted to create a shared GS1 Schema that could be loaded during Schema Validation.

The ajv.js library supports combining JSON Schema before validation using the $ref keyword https://ajv.js.org/guide/combining-schemas.html#combining-schemas-with-ref

One related question. Does the Transmute Library support a way to bypass JSON Schema validation. We have a use case were we like to directly run the JSON Schema validation using the ajv.js library and still use the Transmute library for the Revocation Check.

OR13 commented 2 weeks ago

Our experience with trace-vocab has lead us to avoid using schemas with $ref.

its possible to support it, but it leads to security / performance issues, and complexity.

I would in general recommend against it, if you have the option to.

OR13 commented 2 weeks ago

I'll leave this issue open, and see if I can add some tests demonstrating support for this.

The problem is that $ref is usually a relative reference, and the base will be an absolute URL, so even if its supported there could be compatibility issues between collections of schemas hosted via https and collections of schemas hosted in a file system.