Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Allow resolving only relative and absolute refs and leave local refs unresolved #27

Closed
mohsen1 opened this issue Aug 9, 2015 · 27 comments

Comments

@mohsen1
Copy link

mohsen1 commented Aug 9, 2015

Per requests here and here users want to resolve a multi-file JSON file into one file without resolving local (fragment URIs) refs. If we can specify which of these types of refs to resolve it would be perfect:

  • Fragment URIs
  • Relative URIs
  • Absolute URIs
@arnaud-deprez
Copy link

+1 :-)

@whitlockjc
Copy link
Owner

I've been thinking of doing this for a while. My plan is to add two new options:

  • remoteRefsOnly
  • localRefsOnly

Then you can resolve all locals only, all remotes only or all of them.

@mohsen1
Copy link
Author

mohsen1 commented Aug 10, 2015

We also need to allow only resolving relative remotte refs and leave absolute ones. This could be the case for a multi-file JSON Schema that uses absolute refs for default/base JSON Schemas from http://json-schema.org/

@whitlockjc
Copy link
Owner

Works for me. I'm sure this seem simple...I look forward to how painful the implementation becomes. ;)

@NadavK
Copy link

NadavK commented Aug 11, 2015

+1
(its a sign of an experienced programmer who realizes in advance that nothing is as simple as it looks)

@whitlockjc
Copy link
Owner

I thought about this some today working on #30. I've not forgotten.

@tobad357
Copy link

tobad357 commented Sep 7, 2015

+1 this would be great as currently using allOf in swagger definitions and then processing through json-ref prduces an error.

If you don't have time I could have a look at it

@whitlockjc
Copy link
Owner

If there is an error with allOf, we should fix that so feel free to file a bug. Other than that, I do have plans on implementing this but I've been working on other things the past few weeks at work. Feel free to submit a PR and I'm always available to guide/help.

@arnaud-deprez
Copy link

Hi,
Could someone tell me what is the status of this ?
Rgds,

@whitlockjc
Copy link
Owner

I've not started yet but I can bump it up in priority.

@arnaud-deprez
Copy link

Ok no problem ! If you can it's nice otherwise I'm already doing a workaround (but I must use some copy/paste right now :-( to avoid using allOf)

@marcelaraujo
Copy link

+1

@sobit
Copy link

sobit commented Oct 27, 2015

+1

@whitlockjc any updates on that issue? need it very much

@marcobrinkmann
Copy link

+1

@whitlockjc
Copy link
Owner

Sorry for the delay. I'll work on it over the weekend. If you've not heard from me, feel free to reply here to throw it in my inbox.

@xhochn
Copy link

xhochn commented Nov 2, 2015

+1

@sobit
Copy link

sobit commented Nov 2, 2015

@whitlockjc just as you suggested, reminding you about the issue. :) thanks a ton for the great work btw!

@whitlockjc
Copy link
Owner

I'm working on it as we speak.

@pleerock
Copy link

pleerock commented Nov 2, 2015

+1 would be nice to have this feature

@htimur
Copy link

htimur commented Nov 3, 2015

+1 for this feature

@arabold
Copy link

arabold commented Nov 11, 2015

We're running into the same problem here. We want to resolve only relative local file paths to consolidate our different files into a single one, but keep all absolute URLs (https://...) and #/definitions/.. (Swagger) intact.

@sobit
Copy link

sobit commented Nov 11, 2015

@whitlockjc is there any progress done on this front? if you're under time pressure, maybe you could point in the right direction so someone else can pick it up instead?

@arabold
Copy link

arabold commented Nov 11, 2015

Here's a pull request a colleague of mine just released: #41

@whitlockjc
Copy link
Owner

I'll take a peek. I apologize for the delay, I've been traveling.

HyperBrain pushed a commit to stashimi/json-refs that referenced this issue Nov 12, 2015
Included new options resolveRemoteRefs, resolveFilRefs and resolveLocalRefs
@mohsen1
Copy link
Author

mohsen1 commented Nov 17, 2015

👍

@aktwang
Copy link

aktwang commented Nov 23, 2015

Hi...Can you show me how to use the new option(s)? I'm using the code from: http://azimi.me/2015/07/16/split-swagger-into-smaller-files.html, and I don't like the fact it expanded the $ref inline for me for the definitions..Thanks!

var resolve = require('json-refs').resolveRefs;
var YAML = require('js-yaml');
var fs = require('fs');

var root = YAML.load(fs.readFileSync('index.yaml').toString());
var options = {
processContent: function (content) {
return YAML.load(content);
}
};
resolve(root, options).then(function (results) {
console.log(YAML.dump(results.resolved));
});

@whitlockjc
Copy link
Owner

The API documentation is located here: https://github.com/whitlockjc/json-refs/blob/master/docs/API.md#resolveRefs Depending on which reference type(s) you want to resolve, update the options you created appropriately.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests