lichunqiang / yii2-swagger

yii2 with swagger-php
https://packagist.org/packages/light/yii2-swagger
MIT License
151 stars 47 forks source link

api_key 在nginx下通过header发送,无法验证。 #7

Closed brucebnu closed 7 years ago

brucebnu commented 7 years ago

新版本的swagger ui 不在使用get验证登录,改用header。apache下正常。 nginx下自定义header, 在nginx.conf 开启 underscores_in_headers on; #默认off api_key会解析为api-key,php无法获取进行验证,报错如下,建议统一api-key

{"securityDefinitions":{"api_key":{"in":"header","type":"apiKey","name":"api_key"}},"swagger":"2.0","schemes":["http"],"info":{"title":"Please take authentication firstly."}}

参考:http://stackoverflow.com/questions/22856136/why-underscores-are-forbidden-in-http-header-names

lichunqiang commented 7 years ago

你可以先通过配置SwaggerApiAction::apiKeyParam改成 api-key来试试。

brucebnu commented 7 years ago

是的,现在是这么处理的,谢谢!