Swagger:禁用特定路径上的安全性 [英] Swagger: disabling security on one particular path
本文介绍了Swagger:禁用特定路径上的安全性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个以以下内容开头的 Swagger 文件
I have a Swagger file that starts with the following
{
"swagger": "2.0",
"basePath": "/api",
"schemes": [
"https"
],
"securityDefinitions": {
"internalApiKey": {
"type": "apiKey",
"name": "AAuthorization",
"in": "header"
}
},
"security" : [
{ "internalApiKey": [ ] }
],
此序言将安全设置应用于文件中的每个路径.例如.
This prolog applies the security setting to every path that follows in the file. Eg.
"paths": {
"/foo": {
"get": {
有什么方法可以仅对一个特定路径或方法禁用安全性吗?
Is there some way I can disable security on just ONE particular Path or Method?
推荐答案
好的.只需将 "security"
属性添加到操作中,并将空数组 []
作为值.
Sure. Simply add the "security"
property to operation with an empty array []
as a value.
有点像
{
"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": [
]
}
将使此操作的安全性无效.
would nullify the security for this operation.
这篇关于Swagger:禁用特定路径上的安全性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文