Comments (6)
The error is in response to this.
JSC can fetch schemas from the web or from the file system, but when fetching from the file system, there are limitations for security reasons. If your schema has an identifier with an http scheme (
http://example.com/my-schema
), it's not allowed to reference schemas with a file scheme (file:///path/to/my/schemas/my-schema.json).
I'm looking into it and there seems to bug where this error is firing when it shouldn't. I should have a fix out this afternoon. I'll also look into improving that error message. It's not very helpful without knowing which file was requested and what the context URL is.
Does your schema have an $id
or $ref
with an http scheme? Without knowing what your schema looks like (and the limited error messaging), I can't say if you are getting this error for good reason, or because of the bug.
from json-schema-core.
Here's an example of something that should cause that error. Because the $id
is http
(network context), it isn't allowed to $ref
a file.
{
"$id": "http://example.com/example.schema.json",
"$schema": "https://json-schema.org/draft/2019-09/schema",
"type": "object",
"properties": {
"foo": { "$ref": "file:///path/to/my/schemas/example.schema.json" }
},
"required": ["foo"]
}
from json-schema-core.
Here's an example schema where I see this error (it doesn't have an $id):
{
"$schema": "https://json-schema.org/draft/2019-09/schema",
"type": "object",
"properties": {
"name": {
"title": "Target Name",
"description": "Target names must begin and end with letters, but may contain numbers, hyphen and underscore.",
"type": "string",
"pattern": "^[A-Za-z]([\\w\\-]*[A-Za-z])?$"
}
},
"required": [
"name"
]
}
I did unsuccessfully try other variations like the $id like in your example and "$id": "file:///path/to/my/schema.json"
from json-schema-core.
There are no $ref
s in that schema, so there shouldn't be any problem. Your schema is fine. You're just hitting the bug.
from json-schema-core.
I just published the fix. Please try it out and let me know if it's working for you.
NOTE: The bug was in json-schema-core, not in json-schema-validator where the bug was reported, so when you update you should expect to see a version bump in the json-schema-core dependency.
from json-schema-core.
Thank you for fixing this!
from json-schema-core.
Related Issues (8)
- Error: https://json-schema.org/draft/2020-12/schema is not a schema. Found a document with media type: application/octet-stream HOT 3
- Default Schema Version HOT 2
- Unhandled Promise Rejections with multiple unresolved $refs HOT 4
- Invalid type value results in an undefined error HOT 7
- โcosntโ in the README HOT 1
- Failed to fetch local file in windows HOT 2
- SHOULD accept application/json and not make application/schema+json a MUST HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from json-schema-core.