I'm interested to understand how to auto-add my custom authorization header to all "try it out" requests with swagger-ui 3.0.6.
In my frontend page I have a dropdown that contains multiple authorization header values. So, what I did with swagger 2.x it was a javascript function with an onchange event that injected the selected authorization header value in the swaggerUI instance.
I cannot reproduce this mechanism with swagger-ui 3.0.6.
Someone could help me?
This question is releated to this one.
Thanks
Asked
Active
Viewed 1,398 times
1
-
How does your custom `Authorization` header look like? – Helen Apr 19 '17 at 13:08
-
X-MyCustomHeader-Name: 'a-value'. With swagger-ui 2.x I do in this way: `var apiKeyAuth = new SwaggerClient.ApiKeyAuthorization("X-MyCustomHeader-Name", 'a-value', "header"); window.swaggerUi.api.clientAuthorizations.add("api_key", apiKeyAuth);` – Luca Apr 19 '17 at 13:11
1 Answers
0
In my frontend page I have a dropdown that contains multiple authorization header values. So, what I did with swagger 2.x it was a javascript function with an onchange event that injected the selected authorization header value in the swaggerUI instance.
I cannot reproduce this mechanism with swagger-ui 3.0.6
Adding authorization headers programmatically is not supported yet in Swagger UI 3.0.x. This is being tracked in https://github.com/swagger-api/swagger-ui/issues/2793.

Helen
- 87,344
- 17
- 243
- 314
-
Hi Helen, what you have written is true and works already in my case, so maybe I did not explain my problem well. In my frontend page I have a dropdown that contains multiple _authorization header values_. So, what I did with swagger 2.x it was a javascript function with an onchange event that injected the selected _authorization header value_ in the swaggerUI instance.
I cannot reproduce this mechanism with swagger-ui 3.0.6. – Luca Apr 20 '17 at 07:26 -