使用-https://swagger.io/docs/specification/2-0/authentication/basic-authentication/
中提到的方法我尝试使用nodejs-摇摇欲坠的OAS2.0。并得到此错误-
{
"message": "unknown security handler: mySec",
"code": "server_error",
"statusCode": 403
}
swagger.yaml中添加的代码为-
securityDefinitions:
mySec:
type: basic
security:
- mySec: []
和已定义的响应全局参数-
responses:
UnauthorizedError:
description: Authentication information is missing or invalid
headers:
WWW_Authenticate:
type: string
,然后在我的/ healthCheck get方法中调用以上响应。
/healthcheck:
# binds a127 app logic to a route
x-swagger-router-controller: healthCheck
get:
description: Returns version of package.json
# used as the method name of the controller
operationId: healthCheckEndpoint
responses:
"200":
description: Success
schema:
# a pointer to a definition
$ref: "#/definitions/SearchReportResponse"
"401":
$ref: "#/responses/UnauthorizedError"