Swagger-ui 2.0 路径没有从顶部获得 Bearer Authorization
Swagger-ui 2.0 path do not get Bearer Authorization from top
当我检查 swagger 时,我的路径“/customers”显示“无 headers 授权”,而我在右上角的“授权”输入中输入了 Bearer 令牌。这就像客户的“安全”道具没有链接到一般的安全定义。在 web Swagger 中,GET /Customers 附近的挂锁是灰色的并且是打开的,当我点击它时它没有显示任何“可用授权”。(邮递员版本正在运行),我找不到为什么,你能帮我吗?
在我的 swagger-ui (2.0)json 文件中,我得到了:
"securityDefinitions": {
"Bearer": {
"type": "apiKey",
"name": "Authorization",
"in": "header",
"description": "Enter your bearer token in the format **Bearer <token>**"
}
},
然后在下面的第二条路径上我输入了“security”:
"/customers": {
"get": {
"tags": ["Customer Search"],
"summary": "find a customer by email, name, tel, ...",
"security": [{ "bearerAuth": [] }],
"parameters": [
{
"name": "email",
"in": "query",
"description": "email",
"required": true,
"type": "string"
},
{
"name": "realmCode",
"in": "query",
"description": "realmCode",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "send customer json file"
}
}
这是我路线的节点 Express JS 代码的开头:
router.get("/customers", async (req: any, res: any) => {
if (!req.headers.authorization)
return res.status(401).json({ error: "no headers authorization" });
else {
```
好的,我找到了:
"security": [{ "Bearer": [] }],
而不是“bearerAuth”:)
当我检查 swagger 时,我的路径“/customers”显示“无 headers 授权”,而我在右上角的“授权”输入中输入了 Bearer 令牌。这就像客户的“安全”道具没有链接到一般的安全定义。在 web Swagger 中,GET /Customers 附近的挂锁是灰色的并且是打开的,当我点击它时它没有显示任何“可用授权”。(邮递员版本正在运行),我找不到为什么,你能帮我吗?
在我的 swagger-ui (2.0)json 文件中,我得到了:
"securityDefinitions": {
"Bearer": {
"type": "apiKey",
"name": "Authorization",
"in": "header",
"description": "Enter your bearer token in the format **Bearer <token>**"
}
},
然后在下面的第二条路径上我输入了“security”:
"/customers": {
"get": {
"tags": ["Customer Search"],
"summary": "find a customer by email, name, tel, ...",
"security": [{ "bearerAuth": [] }],
"parameters": [
{
"name": "email",
"in": "query",
"description": "email",
"required": true,
"type": "string"
},
{
"name": "realmCode",
"in": "query",
"description": "realmCode",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "send customer json file"
}
}
这是我路线的节点 Express JS 代码的开头:
router.get("/customers", async (req: any, res: any) => {
if (!req.headers.authorization)
return res.status(401).json({ error: "no headers authorization" });
else {
```
好的,我找到了:
"security": [{ "Bearer": [] }],
而不是“bearerAuth”:)