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

Bug when using external references? #96

Open
kgryte opened this issue Oct 21, 2015 · 5 comments
Open

Bug when using external references? #96

kgryte opened this issue Oct 21, 2015 · 5 comments

Comments

@kgryte
Copy link

kgryte commented Oct 21, 2015

Any reason why the following should fail? (see https://github.com/kgryte/is-my-json-valid/blob/master/test/failing.js)

var schema = {
    "id": "test-schema",
    "$schema": "http://json-schema.org/draft-04/schema#",
    "description": "Test schema.",
    "type": "object",
    "definitions": {
        "port": {
            "description": "schema for a port",
            "type": "integer",
            "minimum": 1024,
            "maximum": 65536
        }
    },
    "properties": {
        "port": {
            "$ref": "#/definitions/port"
        }
    },
    "required": [
        "port"
    ]
}

Test:

tape('external reference', function(t) {
    var validate = validator({
        '$ref': '#ext'
    }, {
        schemas: {'ext':schema}
    })
    t.notOk(validate({}), 'should be invalid') // valid
    t.notOk(validate({port:80}), 'should be invalid') // valid
    t.end()
})

As demonstrated in other tests, validate( 'beep' ) will fail, but for an object having internal reference definitions, these are not being resolved.

@kgryte
Copy link
Author

kgryte commented Nov 1, 2015

@chrahunt Any thoughts on this?

@kgryte
Copy link
Author

kgryte commented Nov 1, 2015

If I use jsen, the tests correctly fail. So I am thinking there is a bug in IMJV when handling external references.

@emilbayes
Copy link
Collaborator

I just confirmed this and had a look at the generated code. I'll try to solve this in the coming week

@kgryte
Copy link
Author

kgryte commented May 28, 2016

@emilbayes Thanks!

@baleevskiy
Copy link

Any updates on this? Facing the same issue

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

3 participants