Coder Social home page Coder Social logo

Comments (6)

jdesrosiers avatar jdesrosiers commented on July 21, 2024

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.

jdesrosiers avatar jdesrosiers commented on July 21, 2024

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.

aecollver avatar aecollver commented on July 21, 2024

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.

jdesrosiers avatar jdesrosiers commented on July 21, 2024

There are no $refs in that schema, so there shouldn't be any problem. Your schema is fine. You're just hitting the bug.

from json-schema-core.

jdesrosiers avatar jdesrosiers commented on July 21, 2024

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.

aecollver avatar aecollver commented on July 21, 2024

Thank you for fixing this!

from json-schema-core.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.