voxpupuli / json-schema

Ruby JSON Schema Validator
MIT License
1.52k stars 241 forks source link

JSON::Validator.validate throws TypeError exception class/object expected #491

Open chibeepatag opened 1 year ago

chibeepatag commented 1 year ago

I'm using ruby 2.7.1 and rails 6.1 When validating the following json against the following schema, JSON::Validator.validate throws TypeError exception class/object JSON: [ { "name": "enable_customer_membership", "value": null }, { "name": "time_zone", "value": "Guam" }, { "name": "company_name", "value": "Demeter Trading Inc." }, ]

Schema: { "id": "https://celine.com/v1/setting.schema.json", "title" : "Setting", "type": "array", "items": { "type": "object", "properties": { "name": { "type": "string", "description": "name of setting" }, "value": { "anyOf": [ { "type": "number" }, { "type": "null" }, { "type": "string" }, { "type": "integer" }, { "type": "boolean" } ] } }, "required": [ "name", "value" ] } }

blerner commented 1 year ago

We encountered this today in our project -- it seems closely connected to a change in Spring, from v4.0.0 to v4.1.1: https://github.com/rails/spring/commit/21e272f73efc75e9f273277fd74fed3ef86ce1eb. Is it possible you have a new version of Spring, and is it possible that downgrading will "resolve" this bug? If so, then it's a bug on Spring...

Physium commented 12 months ago

am facing this issue as well. downgrading to 4.1.0 works. not sure how spring is causing validate! to fail...