Closed
Description
Problem
Trying to load a schema from a relative location in the file system fails on Windows:
const validateOpenApi = await validate("./schemas/v3.1/schema.json");
results in
RetrievalError: Unable to load resource 'file:///C:/git/OpenAPI-Specification/schemas/v3.1/schema.json'.
❯ get node_modules/@hyperjump/browser/lib/browser/browser.js:29:13
❯ getSchema node_modules/@hyperjump/json-schema/lib/schema.js:31:18
❯ Module.validate node_modules/@hyperjump/json-schema/lib/core.js:21:18
❯ tests/v3.1/examples.test.js:14:25
How to reproduce
git clone https://github.com/OAI/OpenAPI-Specification
cd OpenAPI-Specification
npm i
npm t
Workaround
Fetching the schema from the file system and registering it works:
registerSchema(JSON.parse(readFileSync("./schemas/v3.1/schema.json","utf8")),"http://localhost/schema");
const validateOpenApi = await validate("http://localhost/schema");
This is rather clumsy and not the documented preferred way to work with file-based schemas on the server.
Metadata
Metadata
Assignees
Labels
No labels