2016-07-20 28 views
0

我在流明中有基本身份验证Api。对于那个Api我整合Swagger-ui使用下面的url:https://github.com/DarkaOnLine/SwaggerLume头部没有发送基本身份验证为swagger-lume

在swagger UI中启用自定义标头。我们做了改变以下2个文件

1招摇,lume.php

 'headers' => [ 
     /* 
     |-------------------------------------------------------------------------- 
     | Uncomment to add response headers when swagger is generated 
     |-------------------------------------------------------------------------- 
     */ 
     /*"view" => [ 
     'Content-Type' => 'text/plain' 
     ],*/ 
     /* 
     |-------------------------------------------------------------------------- 
     | Uncomment to add request headers when swagger performs requests 
     |-------------------------------------------------------------------------- 
     */ 
     "request" => [ 
    'Authorization ' => 'Basic YWRtaW46YWRtaW4=' 
    ], 
    ], 

2.生成的代码index.blade.php如下

basicAuth= "Basic " + btoa("admin:admin"); 
swaggerUi.api.clientAuthorizations.add("key", new SwaggerClient.ApiKeyAuthorization("Authorization", basicAuth, "header")); 

但头没有发送请求。请检查下面的图片以供参考

enter image description here

请建议,如何解决这个问题。

回答

0

我在api文件的注释语法中定义了很多securityDefinitions。我发现问题来自json文件。删除下面的注释语法,然后头接受ajax调用。

..., 
"securityDefinitions":{ 
    "administrator":{ 
     "type":"basic", 
     "description":"The administrator." 
    }, 
    "supervisor":{ 
     "type":"basic", 
     "description":"A supervisor." 
    }, 
    "customer":{ 
     "type":"basic", 
     "description":"A customer." 
    } 
}, 
...