Swagger: disabling security on one particular path

后端 未结 1 507
伪装坚强ぢ
伪装坚强ぢ 2020-12-06 06:15

I have a Swagger file that starts with the following

{
    \"swagger\": \"2.0\",
    \"basePath\": \"/api\",
    \"schemes\": [
        \"https\"
    ],
             


        
相关标签:
1条回答
  • 2020-12-06 06:32

    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.

    0 讨论(0)
提交回复
热议问题