You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Forgive me if this is the same as all these issues, but I am new to JSON schemas and the tooling around it so would like clarification if I am misunderstanding something. I am using Schema 2020-12 with .json files on a filesystem with the json files nested in folders.
I am setting the URI to a bogus URL but from what I read on json-schema.org, it does not mean anything is necessarily downloaded.
I am loading both schemas
import Ajv from 'ajv/dist/2020';
import addFormats from 'ajv-formats';
import * as example_1 from '../../parent_folder/folder_1/example_1.json';
import * as example_2 from '../../parent_folder/folder_2/example_2.json';
const ajv = new Ajv({ allErrors: true });
addFormats(ajv);
ajv.addSchema(example_1, 'ex1')
ajv.addSchema(example_2, 'ex2')
However when running, the library tries to download the schemas defined in the $id which don't exist.
To avoid the library from trying to download the JSON via HTTPS I disabled the http resolver (I am running via CLI) so that the file resolver is used instead
Which instead results in an error in the library trying to read the root folder of my project instead of reading the files in /path/to/my/project/root/schemas/json
stack: 'ResolverError: Error opening file "/path/to/my/project/root/" \n' +
'EISDIR: illegal operation on a directory, read\n' +
' at /path/to/my/project/root/node_modules/@apidevtools/json-schema-ref-parser/lib/resolvers/file.js:52:20\n' +
' at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read_file_context:52:12)',
code: 'ERESOLVER',
message: 'Error opening file "/path/to/my/project/root/" \n' +
I am using json-schema-to-typescript which uses this library as an underlyging library so I have the same error. Using AJV with the URIs seems to work fine.
If I change the $ref values to be relative, then json-schema-ref-parser compiles ok, but then AJV complains it cannot find the relative links.
Forgive me if this is the same as all these issues, but I am new to JSON schemas and the tooling around it so would like clarification if I am misunderstanding something. I am using Schema 2020-12 with
.json
files on a filesystem with the json files nested in folders.example_1.json
example_2.json
I am setting the URI to a bogus URL but from what I read on json-schema.org, it does not mean anything is necessarily downloaded.
I am loading both schemas
However when running, the library tries to download the schemas defined in the
$id
which don't exist.To avoid the library from trying to download the JSON via HTTPS I disabled the
http
resolver (I am running via CLI) so that the file resolver is used insteadWhich instead results in an error in the library trying to read the root folder of my project instead of reading the files in
/path/to/my/project/root/schemas/json
I am using json-schema-to-typescript which uses this library as an underlyging library so I have the same error. Using AJV with the URIs seems to work fine.
If I change the
$ref
values to be relative, then json-schema-ref-parser compiles ok, but then AJV complains it cannot find the relative links.I don't want to use FQPN of
file///
for multiple reasons which are out of scope here.Can someone clarify if I am understanding the spec correctly, if what I want to do is possible and if the tooling currently supports it?
The text was updated successfully, but these errors were encountered: