Skip to content

Relative references using $def are being URL encoded #356

Open
@drpump

Description

@drpump

We are using a $defs section in our schemas. Schemas within the $defs section are referenced via local file references, and these schemas can themselves have cross references to other files. The ref parser is correctly injecting a$defs cross-reference but replacing the $defs with %24defs (i.e. it is applying URL encoding). I don’t think this behaviour is correct: while $ is a reserved character in the URIs RFC, it is designated as a sub-delimiter

For example in the parent file:

{
  “properties”: {
     “foo”: “string”
  },
  ”$defs”: {
    “myschema”: {
       “$ref”: “./myschema.json”
    },
    ”otherschema”: {
       “$ref”: “./otherschema.json”
    }
  }
}

And the myschema.json file:

{
      “allOf”: [
        { “$ref”: “./otherschema.json” },
        { 
           “properties”: {
              “someProp”: “string”
           }
        }
      ]
}

Flattening results in:

{
  “properties”: {
     “foo”: “string”
  },
  ”$defs”: {
    “myschema”: {
      “allOf”: [
        { “$ref”: “#/%24defs/otherschema.” },
        { 
           “properties”: {
              “someProp”: “string”
            }
        }
      ]  
    },
    ”otherschema”: {
         “properties”: {
            “otherProp”: “string”
         }
     }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions