我有一个Swagger文件,从以下开始
{
"swagger": "2.0",
"basePath": "/api",
"schemes": [
"https"
],
"securityDefinitions": {
"internalApiKey": {
"type": "apiKey",
"name": "AAuthorization",
"in": "header"
}
},
"security" : [
{ "internalApiKey": [ ] }
],
Run Code Online (Sandbox Code Playgroud)
此prolog将安全设置应用于文件中的每个路径.例如.
"paths": {
"/foo": {
"get": {
Run Code Online (Sandbox Code Playgroud)
有没有什么方法可以在一个特定的路径或方法上禁用安全性?
Ron*_*Ron 18
当然.只需将"security"属性添加到操作,并将空数组作为值.
所以像
{
"tags": [
"pet"
],
"summary": "Updates a pet in the store with form data",
"description": "",
"operationId": "updatePetWithForm",
"consumes": [
"application/x-www-form-urlencoded"
],
"produces": [
"application/json",
"application/xml"
],
"parameters": [
{
"name": "petId",
"in": "path",
"description": "ID of pet that needs to be updated",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "Pet updated."
}
},
"security": [
]
}
Run Code Online (Sandbox Code Playgroud)
会使此操作的安全性无效.
| 归档时间: |
|
| 查看次数: |
4474 次 |
| 最近记录: |