Swagger:在一个特定路径上禁用安全性 [英] Swagger: disabling security on one particular path
本文介绍了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?
解决方案
Sure. Simply add the "security"
property to operation with an empty array []
as a value.
So something like
{
"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屋!
查看全文