pboettch / json-schema-validator

JSON schema validator for JSON for Modern C++
Other
470 stars 135 forks source link

Map remote uri path to a schema? #196

Closed sam20908 closed 2 years ago

sam20908 commented 2 years ago

I'm looking to transition to this library to validate schemas from rapidjson, but I wasn't sure if this provides a way for the user to resolve uris on their own. For example, I have schemas embed into the application, so they don't actually exist in the path, but rapidjson allows me to create a map to resolve them via https://rapidjson.org/md_doc_schema.html#Remote.

Is the same thing possible with this library? Thanks!

pboettch commented 2 years ago

Yes, it does. Via a callable (loader) provided at the instantiation of the validator by you. It is called for every schema-ref which cannot be resolved by the provided schemas.

Checkout the small example app here: https://github.com/pboettch/json-schema-validator/blob/master/app/json-schema-validate.cpp#L67

sam20908 commented 2 years ago

Yep, that works!