Skip to content

Error resolving $ref for property alongside top-level $ref #48

Closed
@taicho

Description

@taicho

All,

I'm having an issue resolving a reference. Having tested a couple scenarios, I was happy to see that providing a top-level reference and included some other properties alongside the $ref netted me a merged/combined object, for example:

Dereferencing this:

{
    "$ref":"http://someuri/myOtherSchema",
    "anotherProperty":"whatever"
}

Results in this (imagining myOtherSchema contains the added properties):

{
    "somePropertyFromMyOtherSchema": "misc",
    "anotherPropertyFromMyOtherSchema":"more",
    "anotherProperty": "whatever"
}

However, if I attempt to dereference the following:

{
    "$ref": "http://someuri/foo",
    "anotherProperty": {"$ref":"http://someuri/blah/some/field/value"}
}

It results in an error ('Error resolving $ref: http://someuri/blah/some/field/value'). It's worth noting that I am using a custom resolver and I changed the $ref urls for this post but removing the top-level $ref results in success i.e. my resolver is working as expected and in fact is a simple in-memory resolver. When this error happens the $ref mentioned in the error never even hits my resolver and its resolution is never attempted. Is having a top-level $ref alongside a property that points to a $ref expressly forbidden by the specification, is this a flaw or a feature of json-schema-ref-parser?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions