Skip to content

Configuration file downloaded 2 times when using configUrl #4825

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

Closed
anfle opened this issue Aug 22, 2018 · 4 comments · Fixed by #6544
Closed

Configuration file downloaded 2 times when using configUrl #4825

anfle opened this issue Aug 22, 2018 · 4 comments · Fixed by #6544

Comments

@anfle
Copy link

anfle commented Aug 22, 2018

Q&A (please complete the following information)

  • Method of installation: npm
  • Swagger-UI version: 3.18.x

Content & configuration

Swagger-UI configuration options:

import SwaggerUI from 'swagger-ui'
import SwaggerUIStandalonePreset from 'swagger-ui/dist/swagger-ui-standalone-preset'

window.onload = function() {
    const ui = SwaggerUI({
        configUrl: '/api/swagger-config.json',
        dom_id: '#swagger-ui',
        presets: [
          SwaggerUI.presets.apis,
          SwaggerUIStandalonePreset
        ],
        plugins: [
          SwaggerUI.plugins.DownloadUrl
        ],
        layout: 'StandaloneLayout',
        filter: true,
        requestInterceptor: function(request) {
            // handle CSRF
            return request;
        },
        responseInterceptor: function (response) {
          // handle json prefix
          return response
        }
    })
})

window.ui = ui

And my swagger-config.json file:

{
  "url": "/swagger-portal.json",
  "filter": true,
  "deepLinking": true,
  "validatorUrl": null
}

How can we help?

My swagger config file (define in configUrl parameter) is downloaded two times (illustrated in the screenshot below).
From the code src/core/index.js and src/core/plugins/configs/spec-actions.js it's normal.
However I think it might be more efficient to check if the requests parameter exists before calling the getConfigByUrl method in the if condition to avoid double downloading.
Maybe I missed something?

Screenshots

swagger

@shockey
Copy link
Contributor

shockey commented Aug 22, 2018

Hmm, yeah, this does seem like it's duplicated. Good catch!

@bnasslahsen
Copy link

Hi,

Is there any workaround for this issue when we use configUrl ?

@lrozenblyum
Copy link

Any ideas for a workaround? onComplete is also called twice which is not nice

@mariem-89
Copy link

@shockey,

Is there any workaround for this bug?
It's really annoying to have the swagger-ui loaded twice.

Thank you guys for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants