비어 있는 전역 security 배열

전역 security가 빈 배열이면 기본 인증 요구사항이 없습니다.

설명

최상위 security: []는 API의 기본 인증 요구사항을 비워 둡니다. 개별 작업에서 별도 요구사항을 지정할 수 있습니다.

잠재적 영향

이 기본값을 따르는 작업은 인증 정보 없이 호출할 수 있는 것으로 문서화됩니다.

해결 방법

공통 인증이 필요하면 전역 security에서 정의된 방식을 참조하세요. 공개할 작업에만 예외를 두고 서버의 인증 정책과 맞추세요.

예시

security: [{exampleSecurity: []}]는 exampleSecurity API 키를 요구합니다. 안쪽의 []는 API 키에 스코프가 없다는 뜻입니다.

변경 전

json
{
  "openapi": "3.0.0",
  "paths": {
    "/": {
      "get": {
        "responses": {
          "200": {
            "description": "ok"
          }
        }
      }
    }
  },
  "security": [],
  "info": {
    "title": "Simple API overview",
    "version": "1.0.0"
  },
  "components": {
    "securitySchemes": {
      "exampleSecurity": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key"
      }
    }
  }
}

변경 후

json
{
  "openapi": "3.0.0",
  "paths": {
    "/": {
      "get": {
        "responses": {
          "200": {
            "description": "ok"
          }
        }
      }
    }
  },
  "security": [
    {
      "exampleSecurity": []
    }
  ],
  "info": {
    "title": "Simple API overview",
    "version": "1.0.0"
  },
  "components": {
    "securitySchemes": {
      "exampleSecurity": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key"
      }
    }
  }
}

참조