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

Invalid references created in bundle method #15

Closed
hielsnoppe opened this issue Mar 31, 2016 · 2 comments
Closed

Invalid references created in bundle method #15

hielsnoppe opened this issue Mar 31, 2016 · 2 comments

Comments

@hielsnoppe
Copy link

I am experiencing issues with the bundle method in a way that it creates broken references. See the following minimal example:

foo.json

{
    "$schema": "http:https://json-schema.org/draft-04/schema#",
    "definitions": {
        "foodef": { "$ref": "bar.json#/definitions/bardef" }
    },
    "type": "object",
    "properties": {
        "prop": {
            "$ref": "#/definitions/foodef"
        }
    }
}

bar.json

{
    "$schema": "http:https://json-schema.org/draft-04/schema#",
    "definitions": {
        "bardef": { "type": "string" }
    }
}

run.js

var $RefParser = require('json-schema-ref-parser');

$RefParser
    .bundle("foo.json")
    .then(function(schema) {
        console.log(JSON.stringify(schema, null, '    '));
    });

Running node run.js > result.json results in

result.json

{
    "$schema": "http:https://json-schema.org/draft-04/schema#",
    "definitions": {
        "foodef": {
            "type": "string"
        }
    },
    "type": "object",
    "properties": {
        "prop": {
            "$ref": "#/definitions/foodef/definitions/bardef"
        }
    }
}

There #/definitions/foodef/definitions/bardef is pointing nowhere.

Am I doing something wrong or is this a bug?

@JamesMessinger
Copy link
Member

I just released version 3.0.0, which includes a fix for a very similar issue. I think it may have fixed this issue as well. Please give it a try and let me know.

I'm going to optimistically close this issue. But feel free to re-open it if I've been too hasty. :)

@hielsnoppe
Copy link
Author

Works for me. Thank you!

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

2 participants