Open utrack opened 1 year ago
Thanks for the kind words, @utrack! :-)
I myself used only definitions inside a single schema file. (A hand-written Swagger API description) I looked at it and had to fix two problems:
validate
option a multi-value option.Once you upgrade to 14.0.0, you'll be able to validate your data by specifying all schemas on the command line:
jsonlint ./example.json -V ../json.schema/form.schema.json \
-V ../json.schema/string.schema.json -V ../json.schema/number.schema.json \
-V ../json.schema/phone.schema.json
The schemas can be passed by a single -V
too, if delimited by commas.
Sub-schemas aren't loaded automatically, because they are passed to the validator as schema content. Not as paths to files with the schemas. There's no concept of a base and relative URLs in AJV, because the original paths are lost.
However, the command-line script knows, what were the paths of schema files. It could load the schemas and if it detects a $ref
reference, which hasn't been loaded explicitly and which has its URL based on the same URL as the parent schema ($id
), it could try loading it automatically. And the same for the main schema referred from the data file ($schema
). Let me try it.
Hi Ferdinand, thanks for maintaining this fork! Looks p awesome :)
Can you clarify how do I actually run the schema validation for me, please?
What I've got:
data JSON (example):
../json.schema/form.schema.json JSON:
Expected:
Actual:
I've tried setting the
json-schema
ref tohttps://json-schema.org/draft-07/schema
but the error for that was the same.