-
-
Notifications
You must be signed in to change notification settings - Fork 155
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
Fix for issue#153-relative server paths in OpenAPI #181
Conversation
@philsturgeon @P0lip |
Sorry @jaishirole, bagsy not it. I'm out in the mountains on a big vacation and cannot help. @P0lip if you're around can you help? Or can you pass it over to somebody who can? |
const fetch = require("node-fetch"); | ||
const {expect} = require("chai"); | ||
|
||
const RELATIVE_SERVERS_OAS3_URL = "https://petstore3.swagger.io/api/v3/openapi.json"; //Petstore v3 json has relative path in "servers" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this PR, glad I'm getting a chance to review it now!
I would prefer to avoid adding dependencies to random URLs, as it can have impacts on stability of the test suite (already not good), and can make things hard for those on unstable or highly locked down environments.
Could you create the smallest replicatable file and save it in there, like test/specs/deep-circular/deep-circular.yaml
has done. Then this test will not need to go over the wire.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey Phil @philsturgeon , thanks much for the review comment. I'll have to mock the fetch from an https URL to get the proposed changes tested without going over the internet. Let me add that and push a commit by tomorrow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey Phil @philsturgeon , please take a look at the latest push. I had to resolve conflicts as the upstream repo had new changes on 08/15. So, there are some merge conflicts that I had to solve. I was able to mock the http url fetch and even added more test cases. Let me know your review comments. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good. If you could trim down the test files I'll be happy to merge this one! Thank you 🕺🏻
"tags": [ | ||
{ | ||
"name": "pet", | ||
"description": "Everything about your Pets", | ||
"externalDocs": { | ||
"description": "Find out more", | ||
"url": "http://swagger.io" | ||
} | ||
}, | ||
{ | ||
"name": "store", | ||
"description": "Operations about user" | ||
}, | ||
{ | ||
"name": "user", | ||
"description": "Access to Petstore orders", | ||
"externalDocs": { | ||
"description": "Find out more about our store", | ||
"url": "http://swagger.io" | ||
} | ||
} | ||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for these updates. when I mentioned making the smallest recreatable fixture files i meant can you trim them down a bunch so its easier to see what theyre actually doing? These megafixtures tend to get used for multiple things as people "find the most relevant one" and that leads to brittle test suites over time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, Phil! Let me trim the size further.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pushed the new commit, Phil.
] | ||
} | ||
}, | ||
"/pet/findByStatus": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could probably wipe out all paths other than the one you need to test, trim off parameters, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, let me keep it to a smaller size.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pushed the new commit, Phil.
Phil @philsturgeon , did the last push too! Hope you'll like it, halved the size of the json files but no compromise on what we wanted to test. :) |
I'm on it to fix the lint errors, not sure why my VS Code didn't catch it earlier. |
@philsturgeon |
Hi Phil @philsturgeon , it looks like the usage of 'Optional chaining' aka |
@philsturgeon Another push for moving away from |
Phil @philsturgeon , the browser tests failed for not having the 'url' module available there. I've changed the code to use the 'url' exported from existing dependency of If you trigger the checks workflow, looking forward to next results now. |
Hi Phil (@philsturgeon ) , not sure what the latest failure is about. Can you help me understand what is still left?
|
@philsturgeon I am seeing what was reported here: #178 (comment) and perhaps it is a known issue and nothing with the code checked-in here. |
@philsturgeon Thanks much for all your guidance on this first PR of mine! |
Issue reference: #153
The relative path could show up in any of these places.
The PR tries to address that when SwaggerParser is given an URL to load the file. The fix doesn't work for non http(s) urls or local file system uploaded files.