json-schema icon indicating copy to clipboard operation
json-schema copied to clipboard

Great library, could use some improvements to the developer experience

Open antonio-ivanovski opened this issue 1 year ago • 6 comments

Hello, great library you have build supporting great amount of JSON Schema spec. I was considering switching from Ajv to this library in order to get away from their schema-no-backward compatibility (eg. 2020-12 cannot be used together with 2019-09 or draft-7). Testing some schemas on the playground, this library passed those mixed-schema-version checks and gave me confidence that this might be it.

But I have some gripes that make this library unusable for me

  • No way to check if schema is registered. There is just the method of registerSchema. I need to be able to check if schema is loaded before registering it.
  • No way to get schema that is behind authentication or served via non-standard media type. I can use to some extent addMediaTypePlugin, but working with dynamic set of of schemas, you are destined to stumble on schemas that don't have the required type for the library
  • No way to pass the JSON schema directly to the validate method, you are required to first registerSchema(jsonSchema, jsonSchema.$id). This coupled with the inability to check if a schema has been registered leads to bad developer experience.
  • Single validator instance per application. Having the ability to separate maybe 2 instance of validator makes sense. Considering that there could be clash of instances between packages. Also maybe I want to pass the validate instance outside of my package and others to use it.

Hope this feedback is helpful!

antonio-ivanovski avatar Nov 29 '24 19:11 antonio-ivanovski