Skip to content

allOf fails to process load properties with external $ref #620

@EtonDoze

Description

@EtonDoze

Here is an example

.
├── models
│   ├── pet.json
│   └── purebred_pet.json (#allOf has properties referring to pet.json)
└── parent.json

parent.json

{
  "swagger": "2.0",
  "info": {
    "title": "flat",
    "version": "1.0.0"
  },
  "definitions": {
    "record": {
      "$ref": "./models/purebred_pet.json"
    }
  }
}

models/pet.json

{
  "type": "object",
  "properties": {
    "color": {
      "type": "string"
    }
  }
}

models/purebred_pet.json

Notice here that pet.json is referenced using relative path which is in the same models folder.

{
  "allOf": [
    {
      "$ref": "./pet.json"
    },
    {
      "type": "object",
      "properties": {
        "breed": {
          "type": "string",
          "sample": "Labrador"
        },
        "mother": {
          "$ref": "./pet.json"
        },
        "siblings": {
          "type": "array",
          "items": {
            "$ref": "./pet.json"
          }
        }
      }
    }
  ]
}

Issue: parser fails with error Unable to load RELATIVE ref: ./pet.json. This happens because the pet.json under the properties is resolved RELATIVE to parent.json instead of purebred_pet.json.
I expect parser needs to resolve pet.json w.r.t. to the origin i.e. purebred_pet.json

I have already found a fix for this issue and PR is on its way.

Related to Issue #616 which only fixed the reference in the parent section of allOf. This issue is about references in the child or properties section of allOf construct.

Attn: @gracekarina

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