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

How is resolveRef working? #26

Open
OliverFischer opened this issue Apr 11, 2016 · 0 comments
Open

How is resolveRef working? #26

OliverFischer opened this issue Apr 11, 2016 · 0 comments

Comments

@OliverFischer
Copy link

Hi,
i have some problems to understand the functionality behind resolveRef in references.js. My simple schema looks like

{
        "description": "A victim schema for our test referencing schemas from json-schema.",
        "definitions": {
            "refOne": {
                "type": "object",
                "properties": {
                    "propertyOne": {
                        "type": "string"
                    },
                    "propertyTwo": {
                        "type": "string"
                    }
                }
            }
        },
        "type": "object",
        "properties": {
            "entityRefOne": {
                "$ref": "#/definitions/refOne"
            }
        }
    }

The code recognizes the ref in the object and tries to resolve the reference by inspecting the root schema node:

for (i = 0; i < loc.length; i = i + 1) {
        if (loc[i] === '') {
            //noinspection JSLint
            continue;
        }
        st = st[loc[i]];
        if (st === undefined) {
            throw new Error("Cannot find ref '" + ref + "' in schema");
        }
    }

After this is done, i have a strange result property .entityRefOne[propertyOne] and cannot access the originale value in a selector like ['$ref=*']. Is this the desired behaviour?

Any help is appreciated, btw. cool project!

Olli

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

1 participant