Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Error in parsing nested json schemas #115

Open
AFactor opened this issue Nov 24, 2014 · 6 comments
Open

Error in parsing nested json schemas #115

AFactor opened this issue Nov 24, 2014 · 6 comments

Comments

@AFactor
Copy link

AFactor commented Nov 24, 2014

Raml parser doesn't attempt to parse or validate the nested schema.
{
"required": true,
"description": "Bulk buy limit attributes",
"type": [
"object",
"null"
],
"$ref": "bulkbuy-schema.json"
}
In the following example it would just treat this as a text. The fact that $ref is there wouldn't mean anything to RAML parser.

@ty10r
Copy link

ty10r commented Dec 2, 2014

I'm seeing this problem as well.
When running raml.loadFile on the raml file found at:

https://github.com/mulesoft/api-console/blob/master/app/examples/github.raml

Most of the embedded post body schemas are being evaluated as text.

@dmartinezg
Copy link

Hi, yes this is an open req for the parser: validation of JSON schemas.

If you guys are aware of a good js library that does JSON schema validation (not only validations of JS objects against a JSON schema) and handles these, we could include it in an updated version of the parser.

@naterkane
Copy link

@dmartinezg this looks to be relatively clean, and active. https://github.com/geraintluff/tv4

@dmartinezg
Copy link

@naterkane correct that is a good library to validate JS objects against a schema, that parser however does not really validate JSON schemas against the JSON schema spec, I just tried this:

var tv4 = require('tv4');
var valid = tv4.validate({}, {'foo': false});
console.log(valid);

and it outputs: true, am I wrong?

@thebinarypenguin
Copy link

@dmartinezg Okay a few things. First when you say that tv4 lets you validate objects against a schema but not schemas against the spec; that is wrong. In fact there is no difference between the 2 operations because a schema is a json object and the spec is a json schema. So tv4 can accomplish this. It's just not easy 😦 .

The biggest problem I've found with tv4 is that any references to other schemas (via the $schema or $ref keywords) must be pre-loaded before attempting to validate. This is a pain.

Here is an example repo to demonstrate my point: https://github.com/thebinarypenguin/tv4-sandbox

So while I don't have a ready solution tv4 can probably be used to create one.

@schmkr
Copy link

schmkr commented May 27, 2015

Maybe this project might be worth looking into for dereferencing $ref properties?
bojand/json-schema-deref-sync.

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

No branches or pull requests

6 participants