Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Schema not found" error after updating to gem version 2.8.1 #424

Open
JaniJegoroff opened this issue Oct 19, 2018 · 7 comments
Open

"Schema not found" error after updating to gem version 2.8.1 #424

JaniJegoroff opened this issue Oct 19, 2018 · 7 comments

Comments

@JaniJegoroff
Copy link

I'm writing API tests with RSpec and I do schema validation as part of the tests. Everything is working fine with json-schema gem version 2.8.0.

After updating json-schema gem to version 2.8.1 I get an error

JSON::Schema::SchemaError:
        Schema not found: http://json-schema.org/draft-06/schema#

Example schema I use

{
  "definitions": {},
  "$schema": "http://json-schema.org/draft-06/schema#",
  "$id": "http://example.com/root.json",
  "type": "array",
  "items": {
    "$id": "#/items",
    "type": "object",
    "required": [
      "id",
      "name"
    ],
    "properties": {
      "id": {
        "$id": "#/items/properties/id",
        "type": "integer"
      },
      "name": {
        "$id": "#/items/properties/name",
        "type": "string",
        "pattern": "^(.*)$"
      }
    }
  }
}
@iainbeeston
Copy link
Contributor

I'm afraid that the gem only supports draft 5 and below. Previously the gem would accept draft 6 but it's behaviour was undefined

@koenrh
Copy link

koenrh commented Oct 19, 2018

That's because the 'draft 6' schema in this gem is currently identified as:

http://json-schema.org/draft/schema# (without the -06 suffix)

https://github.com/ruby-json-schema/json-schema/blob/9f19eb2d9787ecff7f1bbdda84ba74c9da0c2370/lib/json-schema/validators/draft6.rb#L47

Context: #376

@JaniJegoroff
Copy link
Author

Ok, but with -06 suffix I can access from browser and download the schema:
http://json-schema.org/draft-06/schema#

Whereas with http://json-schema.org/draft/schema# --> 404

@iainbeeston
Copy link
Contributor

iainbeeston commented Oct 19, 2018

At one point that was correct, but they kept changing the url. Regardless, the gem doesn't support draft 6 syntax, and I'd recommend using draft 5 until we have a chance to fix that

nusnewob added a commit to uktrade/ci-pipeline that referenced this issue Jun 25, 2019
@nruth
Copy link

nruth commented Jun 6, 2020

Sorry to post on a 2 year old thread, but just hit this now & wondering if anything has changed, and whether "draft" refers to the json-api spec or the schema trying to describe it, since the spec has been v1 for a while?

@nruth
Copy link

nruth commented Jun 6, 2020

To answer my own question (sorry for the noise!) it looks like "draft" refers to the json-schema version, and this gem is unmaintained / incompatible with the version the jsonapi schema is written in, so better to try with https://github.com/davishmcclurg/json_schemer and adapt the rspec matcher in that post to the other gem.

I ended up here while following a Thoughtbot blog post + googling for a pre-existing json-api schema.

@tomdaly
Copy link

tomdaly commented Dec 19, 2022

hi, bumping this issue as I have encountered the same issue in v3.0.0

the README now states that v3.0.0 supports Draft 6, but it does not support it via the $schema property or URI function if the correct URI for draft 6 is used (as found on the json-schema.org specification links page):

https://json-schema.org/draft-06/schema

but does work if the $schema URI is specified as:

http://json-schema.org/draft/schema#

it seems that the URI for the meta-schema at this line needs to be updated to be able to correctly use draft v6:
https://github.com/voxpupuli/json-schema/blob/master/lib/json-schema/validators/draft6.rb#L47

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants