-
Notifications
You must be signed in to change notification settings - Fork 9k
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
Multiple swagger tags not expanding issue 6996 #9050
Multiple swagger tags not expanding issue 6996 #9050
Conversation
Note: You can check this out with: |
Hi there, thanks for your work, I had a brief look at it and LGTM. I am just a fellow contributor, so can not give a final review. Maybe you could add tests if applicable, so if the maintainers will review this PR, you don’t have to do it then and wait for another review cycle :) Cheers Mathis |
@rhwilburn thanks for looking into this. Reviewing this is on my radar already. As this is the single most critical code for performing lazy resolution, I'll need to looks into this carefully. |
Hi @rhwilburn, Thanks again for the PR. I've studied the changes and I have couple of questions: Q1AFAICT |
I would suggest the following:
export const requestResolvedSubtree = path => system => {
// poor-man's array comparison
// if this ever inadequate, this should be rewritten to use Im.List
const isPathAlreadyBatched = requestBatch
.map(arr => arr.join("@@"))
.indexOf(path.join("@@")) > -1
if(isPathAlreadyBatched) {
return
}
requestBatch.push({ path, system })
debResolveSubtrees()
} Now the Would that work for you @rhwilburn? |
Good catch; yes the url would be required and must be unique in my approach. I would agree its a clumbsy approach as it could be legitimate to have the same swagger spec display twice on a given HTML page for someone. It could also be as you say that the swagger url is empty twice which would also be an issue. I think the changes you have proposed make sense so will update it with them and have a look. |
SpecUrl removed as it is not unique enough to be used for spec references
…s://github.com/rhwilburn/swagger-ui into multiple-swagger-tags-not-expanding-issue-6996
@char0n I have made the changes you suggested |
Hi @rhwilburn, The changes you've introduced were unfortunately failing most of the test. I've pushed two additional commits to this PR which fix the issues. Here is the list of the issues I was able to identify: 1It's best to avoid modifying iterable (in this case array) while iterating it. Referring to 2By using delete operator, you're creating sparse array, which will cause issues further in the loop Referring to a = [1, 2]
a.lenght; // 2
delete a[1]
a // [1, empty]
a.length; // 2 3
|
@rhwilburn thanks for opening this up and pushing for a workable solution. When the tests pass, I'll merge the PR. |
Description
Motivation and Context
When you use more than one swagger UI instance in a single webpage and require operations to be expanded by default, the instances fight against each other, resulting only the first swagger UI HTML instance rendering and the other instances spin loading until manually toggling the operations.
This fixes issue: #6996
Fixes #6996
How Has This Been Tested?
I have manually tested by using 3 swagger UI specs (all locally hosted; as they seem to give the problem much worse than public internet URLs as delays in the internet will reduce race conditions that reproduce this issue.
Specifically I updated dev-helper-initializer.js and index.html under the dev-helpers folder and used
npm run dev
commandI have tried some external URLs for swagger spec like Petshop example.
I have tested on Windows using Chrome
I did two weeks of research to solve this issue; despite the small amount of code change. I had originally wanted to use reducers.js but found that the changes were getting large and other problems were being introduced. Due to my non familiarity with Redux, I didn't want to take on a big refactoring, so the changes have been limited to a single file.
Screenshots (if appropriate):
Screenshots of the issue are in the issue mentioned previously.
Checklist
My PR contains...
src/
is unmodified: changes to documentation, CI, metadata, etc.)package.json
)My changes...
Documentation
Automated tests