-
Notifications
You must be signed in to change notification settings - Fork 92
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
JSON References aren't properly URL-decoded #72
Comments
json-refs properly resolves all references in the examples provided by @BigstickCarpet. So json-refs is not the issue, unless The problem is Sway is attempting to use the raw
@BigstickCarpet points out that JSON Pointers are suppose to be URI encoded and I'm not sure I read the same but I will revisit it. |
I originally posted this issue for Swagger Editor, not Sway (original issue here). As mentioned there, I think To reproduce the bug, just paste either of my examples above at http://editor.swagger.io |
I understand but since swagger-editor is getting json-refs from sway and json-refs fully resolves all references properly, I'm not sure how json-refs itself is the culprit. (json-refs is potentially the culprit for the false warning but I think since json-refs handles encoded/decoded URIs, sway should too and option 1 suggested above is my suggested fix.) What I am seeing is that sway is reporting an erroneous To further explain what I mean, if I take either of your documents and use the following code, neither report the 'use strict'
var JsonRefs = require('json-refs');
var Sway = require('sway');
function processResults (header, results) {
console.log('%s: %s', header, results.length);
results.forEach(function (result) {
console.log(' %s: %s', JsonRefs.pathToPtr(result.path), result.message);
});
console.log();
}
Sway.create({
definition: './testing.yaml'
})
.then(function (api) {
var results = api.validate();
processResults('Errors', results.errors);
processResults('Warnings', results.warnings);
})
.catch(function (err) {
console.error(err);
}); When I run this against your first example, here is the output:
So if json-refs is resolving things properly and sway is only reporting the warning (erroneously I agree), where is this other error coming from? |
Copying @saharj. |
Just to be complete, here is an example of json-refs handling these references properly:
Had json-refs failed to resolve any reference, it would had croaked and you would had seen an error like this:
|
Any news regarding this issue? |
@whitlockjc Do you think that you'll be able to look into this soon? |
Yes. I haven't had a lot of time recently to put into json-refs but I will do my best to get something out this week. |
Which week? 😁 Just kidding. |
Just to summarize what I think is necessary:
I think earlier I mentioned this as an either/or and I don't think that is accurate. Can someone confirm? |
I honestly don't know the details. I think that @BigstickCarpet would have to confirm. |
First pass at this one is a pain. I can reproduce it of course but the internal model for circulars/dependencies makes it painful. I'll keep at it. |
This was fixed in |
Swagger Editor erroneously shows "Reference could not be resolved" errors for JSON references that contain URL-encoded characters. For example, "#/definitions/foo%20bar" instead of "#/definitions/foo bar". According to RFC 6901, sections 5 & 6, JSON pointers should be URL-encoded.
Here's a simplistic example: https://gist.github.com/BigstickCarpet/5ad1a760acbb598d38c5dbba223eb9bd
And here's a more real-world example: https://gist.github.com/BigstickCarpet/e867ccd425e730634ee71f43c462a34f
As far as I know, Swagger Editor uses json-refs under the hood to do its JSON Pointer decoding. json-refs has the correct logic for decoding URL-encoded JSON Pointers, so maybe Swagger Editor is just using an older version of json-refs? Maybe @whitlockjc can provide more info.
Copied from swagger-api/swagger-editor#871, as this is apparently an issue with Sway.
/cc @BigstickCarpet
The text was updated successfully, but these errors were encountered: