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

Bug in resolving many local reference on a document of remote reference #93

Closed
flaviolsousa opened this issue Aug 26, 2016 · 10 comments
Closed

Comments

@flaviolsousa
Copy link

I could not understand why occurs that... but here is the case.
PS: you could make a flow chart explaining what happens in this crazy code 😄

/public/MainDoc.yml

paths:
  $ref: 'ReferredDoc.yml#/definitions/FirstRef'

/public/ReferredDoc.yml

definitions:

  FirstRef:
    levelA:
      $ref: '#/definitions/LevelA'
    levelC_2:
      $ref: '#/definitions/LevelC'

  LevelA:
    levelB:
      $ref: '#/definitions/LevelB'

  LevelB:
    levelC:
      $ref: '#/definitions/LevelC'

  LevelC:
    name: item

Result:

{
  "paths": {
    "levelA": {
      "levelB": {
        "levelC": {
          "$ref": "#/definitions/LevelC"
        }
      }
    },
    "levelC_2": {
      "name": "item"
    }
  }
}

Here a code that simule the case:
https://github.com/flaviolsousa/validate-model-swagger-web

You need see this files:

  • /public/homeService.js (function readYaml)
  • /public/MainDoc.yml
  • /public/ReferredDoc.yml

This problem in one of my documents occurs 19 times.
I am available to help them in what was needed.

Thanks in advance!

@whitlockjc
Copy link
Owner

This "crazy code" is being cleaned up but can you tell me what version of json-refs you're using?

@flaviolsousa
Copy link
Author

I think is the last!

"json-refs": "^2.1.6"

Note: "Crazy Code" is a light joke in my country ... sorry if I offended. I spoke in order to indicate that is very complex code for me. Recursion, I'm in ... but detect circular references should not be an easy task.

@whitlockjc
Copy link
Owner

No offense taken. I am in the process of cleaning it up a little, more for performance than anything. Let me see if I an figure out what is up with your situation.

diegode pushed a commit to medallia/json-refs that referenced this issue Sep 13, 2016
@diegode
Copy link

diegode commented Sep 13, 2016

Reproduced here: #95

@whitlockjc
Copy link
Owner

This is a duplicate of #80.

@diegode
Copy link

diegode commented Sep 15, 2016

@whitlockjc I think this is a different issue, since #80 happens only when restricting to resolve non-local references (i.e. with parameters -I relative -I remote), but this happens without using filters.
This is why I created a pull request to fix #80 (#94) but for this issue I created a pull request just to reproduce it (#95).

@whitlockjc
Copy link
Owner

I think the steps to reproduce #80 used filters but the problem is a general one. If you resolve only a portion of a remote document (Example: ReferredDoc.yml#/definitions/FirstRef), this problem arises. Both describe the same situation.

@whitlockjc
Copy link
Owner

And sorry for the places where I'm commenting that this is fixed locally. Basically, I've rewritten the resolution code locally to not only fix this issue (and more) but also to fix performance described in #87. The thing is it's a lot of work and I've got a good bit of local changes that fix things like this and #97 but it's not done so there's no commits on master yet.

I will be working on this over the next few days and hopefully fixing all outstanding issues around circular references, external references and performance.

@diegode
Copy link

diegode commented Sep 15, 2016

@whitlockjc ok, I understand. Thank you! :)

@diegode
Copy link

diegode commented Sep 28, 2016

@whitlockjc any update on this? please tell me if there's anything I can do to help.

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

3 participants