【发布时间】:2017-09-12 20:20:17
【问题描述】:
我有一个 Web API (ASP.NET Core),我正在尝试调整 swagger 以从中进行调用。 调用必须包含 Authorization 标头,并且我正在使用 Bearer 身份验证。 来自 Postman 等第三方应用程序的呼叫运行良好。 但是我在为 swagger 设置标题时遇到了问题(由于某种原因,我没有收到标题)。这就是现在的样子:
"host": "localhost:50352",
"basePath": "/" ,
"schemes": [
"http",
"https"
],
"securityDefinitions": {
"Bearer": {
"name": "Authorization",
"in": "header",
"type": "apiKey",
"description": "HTTP/HTTPS Bearer"
}
},
"paths": {
"/v1/{subAccountId}/test1": {
"post": {
"tags": [
"auth"
],
"operationId": "op1",
"consumes": ["application/json", "application/html"],
"produces": ["application/json", "application/html"],
"parameters": [
{
"name": "subAccountId",
"in": "path",
"required": true,
"type": "string"
}
],
"security":[{
"Bearer": []
}],
"responses": {
"204": {
"description": "No Content"
},
"400": {
"description": "BadRequest",
"schema": {
"$ref": "#/definitions/ErrorResponse"
}
},
"401": {
"description": "Unauthorized",
"schema": {
"$ref": "#/definitions/ErrorResponse"
}
},
"500": {
"description": "InternalServerError",
"schema": {
"$ref": "#/definitions/ErrorResponse"
}
}
},
"deprecated": false
}
},
【问题讨论】:
-
我用 firebase stackoverflow.com/questions/61540706/…
标签: c# asp.net-core swagger-ui