This will only work if you a security definition called “authorization” in your 
spec? otherwise swagger-ui will not send it.

 

 

 

From: <[email protected]> on behalf of swaggerUser 
<[email protected]>
Reply-To: "[email protected]" 
<[email protected]>
Date: Wednesday, 13 July 2016 at 13:55
To: Swagger <[email protected]>
Subject: Can not read header param from Filter

 

Hi, 

 

I am using swagger with Jersey.

I am trying to send header parameter through index.html so that all APIs will 
get that as a header param, and I can see that as well into te CURL stmt.

 

I added this to my index.html:

 

 swaggerUi.api.clientAuthorizations.add("key", new 
SwaggerClient.ApiKeyAuthorization("authorization", "authValue", "header"));

 

But when I try to read this header param from filter, I am getting null value.

 

If I execute the same API through Post or SoupUI, then filter is reading the 
header parameter "authorization".

 

I tried reading the header param as this in filter:

 

public void doFilter(ServletRequest request, ServletResponse response,

FilterChain filter) throws IOException, ServletException {

 

HttpServletRequest req= (HttpServletRequest) request;

 

 Enumeration<String> headerNames = req.getHeaderNames();

 

if (headerNames != null) {

     while (headerNames.hasMoreElements()) {

    String key = headerNames.nextElement();

               

 

    System.out.println("Header key: " + key);

   System.out.println("Header value: " + req.getHeader(key));

 

}

 

while debugging I get one of this :

access-control-request-headers = accept, authorization

 

Please help. 

 

Thanks,

 

 

-- 
You received this message because you are subscribed to the Google Groups 
"Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to