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

allOf fails to resolve RELATIVE ref #616

Closed
EtonDoze opened this issue Jan 7, 2018 · 4 comments
Closed

allOf fails to resolve RELATIVE ref #616

EtonDoze opened this issue Jan 7, 2018 · 4 comments
Assignees

Comments

@EtonDoze
Copy link
Contributor

EtonDoze commented Jan 7, 2018

Here is an example

.
├── models
│   ├── pet.json
│   └── fancy_pet.json    #inherits pet.json using allOf
└── parent.json

parent.json

{
  "swagger": "2.0",
  "paths": {
    "/pet": {
      "get": {
        "responses": {
          "200": {
            "schema": {
              "$ref": "./models/pet.json"
            }
          }
        }
      }
    },
    "/fancy-pet": {
        "responses": {
          "200": {
            "schema": {
              "$ref": "./models/fancy_pet.json"
            }
          }
        }
      }
    }
  }
}

models/pet.json

{
  "type": "object",
  "properties": {
    "id": {
      "type": "integer",
      "format": "int64"
    },
    "name": {
      "type": "string",
      "example": "Cooper"
    }
  }
}

models/fancy_pet.json

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

{
  "allOf": [
    {
      "$ref": "./pet.json"
    },
    {
      "properties": {
        "breed": {
          "type": "string",
          "example": "Labrador"
        }
      }
    }
  ]
}

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

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

CC: @tzimisce012

@EtonDoze EtonDoze changed the title allOf fails to load RELATIVE ref allOf fails to resolve RELATIVE ref Jan 7, 2018
EtonDoze added a commit to EtonDoze/swagger-parser that referenced this issue Jan 7, 2018
@gracekarina
Copy link
Contributor

gracekarina commented Jan 7, 2018

@EtonDoze Hi, is this related to #567?
or this maybe? #604

@EtonDoze
Copy link
Contributor Author

EtonDoze commented Jan 7, 2018

@gracekarina , its similar #604 but not same.
I created a PR #617 to fix this #604.

@gracekarina gracekarina self-assigned this Jan 7, 2018
gracekarina added a commit that referenced this issue Jan 7, 2018
Fix for issue #616 allOf fails to resolve RELATIVE ref
@gracekarina
Copy link
Contributor

@EtonDoze please check out the merge, to close the ticket

@EtonDoze
Copy link
Contributor Author

EtonDoze commented Jan 8, 2018

Closing it as its fixed via #617

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