Skip to content

External json schema document reference

LateApexEarlySpeed edited this page Mar 9, 2024 · 1 revision

External json schema document reference

Besides of internal sub schema resource reference (inside current json schema document) support automatically, implementation supports external schema document reference support by:

  • local schema text
var jsonValidator = new JsonValidator(jsonSchema);
string externalJsonSchema = File.ReadAllText("schema2.json");
jsonValidator.AddExternalDocument(externalJsonSchema);
ValidationResult validationResult = jsonValidator.Validate(instance);
  • remote schema url (library will retrieve actual schema content by access network)
var jsonValidator = new JsonValidator(jsonSchema);
await jsonValidator.AddHttpDocumentAsync(new Uri("http://this-is-json-schema-document"));
ValidationResult validationResult = jsonValidator.Validate(instance);