Skip to content
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

Sending headers doesn't work #151

Closed
airborn opened this issue Feb 19, 2013 · 1 comment
Closed

Sending headers doesn't work #151

airborn opened this issue Feb 19, 2013 · 1 comment

Comments

@airborn
Copy link

airborn commented Feb 19, 2013

I've downloaded latest version from git, configured it this way:

window.swaggerUi = new SwaggerUi({
    discoveryUrl:"http://localhost:8080/api-docs",
    dom_id:"swagger-ui-container",
    supportHeaderParams: true,
    headers: {"Authorization": "Basic YWRtaW46YWRtaW4="},
    supportedSubmitMethods: ['get', 'post', 'put'],
    onComplete: function(swaggerApi, swaggerUi){
        if(console) {
            console.log("Loaded SwaggerUI")
            console.log(swaggerApi);
            console.log(swaggerUi);
        }
      $('pre code').each(function(i, e) {hljs.highlightBlock(e)});
    },
    onFailure: function(data) {
        if(console) {
            console.log("Unable to Load SwaggerUI");
            console.log(data);
        }
    },
    docExpansion: "none"
});

And Swagger is not sending headers. Am I missing something?

@fehguy
Copy link
Contributor

fehguy commented Feb 22, 2013

Hi, as of now, you can send one header by default in swagger-ui, am looking into sending multiple headers by default.

The idea is that an api_key can be sent in every request from the UI, from the api key input box. You can configure this to send an authorization header like BasicAuthentication, though, like such:

apiKeyName: "Authorization",
headers: {"Authorization": "Basic YWRtaW46YWRtaW4="},
supportHeaderParams: true,

That says "the key to send by default" is Authorization and the value is in the headers hash. Finally, you have to enable sending the header by default, which is the supportHeaderParams value.

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

No branches or pull requests

2 participants