-
Notifications
You must be signed in to change notification settings - Fork 9k
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
Authorization for the inital fetching of swagger spec file #1503
Comments
Same question here, is it possible to add field "headers" to the SwaggerUi object, something like that
Thanks |
Has the same question. From the documentation here https://github.com/swagger-api/swagger-ui, looks like we can use "authorizations" option to fetch the swagger spec, original quoting as:
But what is the right JSON structure for |
you cannot add headers directly when initializing the swaggerUi. You should be using this syntax:
This will apply the |
@fehguy Thanks, and this is working well. But this setting is not only for loading swagger doc, it also applies to the real API calls. It would be better if has separate setting for loading swagger and API calls since sometimes the the authorization of API calls is different from loading swagger spec. |
Define a security requirement on your API then. If there is none, then any authorization will apply. If there is a security requirement defined, and the name is different from the one you use to fetch the spec, it won't be used. |
Could you comment how to achieve that in version 3 of the UI? Thanks |
Please follow #2793. |
Hello,
I'm using 2.1.1, I have the same problem as reported and fixed in swagger-api/swagger-js#445 which is that our swagger spec file is not publicly accessible, you have to be authenticated and so the request to get the spec file must have an X-auth-token HTTP header.
i tried to do the same way as addApiKeyAuthorization() in index.html but it can't work because
window.swaggerUi.api
is not yet defined, it gets defined afterwindow.swaggerUi.load();
which loads the spec file.So, is there a way to add authorizations before the spec gets loaded?
Thanks
The text was updated successfully, but these errors were encountered: