정의되지 않은 작업별 보안 스킴 참조

작업별 보안 요구 사항이 올바른 스킴을 참조하도록 하세요.

설명

작업의 security는 전역 요구사항을 재정의합니다. 여기에 적은 각 이름을 components.securitySchemes에 정의하세요.

잠재적 영향

참조한 방식을 찾을 수 없으면 클라이언트가 해당 작업에 필요한 인증 정보를 보내지 못할 수 있습니다.

해결 방법

작업에서 사용하는 인증 방식과 스코프를 서버 설정에 맞추세요. OAuth2와 OpenID Connect 외의 방식은 빈 스코프 배열 []를 사용합니다.

예시

예시는 GET /가 참조하는 petstore_auth를 정의합니다. 공급자의 HTTPS 엔드포인트를 지정하고 클라이언트와 인증 서버에서 PKCE를 설정하세요. read:pets와 write:pets는 예시 스코프입니다. 실제 작업에 필요한 것만 요구하세요.

변경 전

json
{
  "openapi": "3.0.0",
  "info": {
    "title": "Simple API overview",
    "version": "1.0.0"
  },
  "paths": {
    "/": {
      "get": {
        "operationId": "listVersionsv2",
        "summary": "List API versions",
        "security": [
          {
            "petstore_auth": [
              "write:pets",
              "read:pets"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "200 response",
            "content": {
              "application/json": {
                "examples": {
                  "foo": {
                    "value": {
                      "versions": [
                        {
                          "status": "CURRENT",
                          "updated": "2011-01-21T11:33:21Z",
                          "id": "v2.0",
                          "links": [
                            {
                              "href": "http://127.0.0.1:8774/v2/",
                              "rel": "self"
                            }
                          ]
                        }
                      ]
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

변경 후

json
{
  "openapi": "3.0.0",
  "info": {
    "title": "Simple API overview",
    "version": "1.0.0"
  },
  "paths": {
    "/": {
      "get": {
        "operationId": "listVersionsv2",
        "summary": "List API versions",
        "security": [
          {
            "petstore_auth": [
              "write:pets",
              "read:pets"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "200 response",
            "content": {
              "application/json": {
                "examples": {
                  "foo": {
                    "value": {
                      "versions": [
                        {
                          "status": "CURRENT",
                          "updated": "2011-01-21T11:33:21Z",
                          "id": "v2.0",
                          "links": [
                            {
                              "href": "http://127.0.0.1:8774/v2/",
                              "rel": "self"
                            }
                          ]
                        }
                      ]
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "regularSecurity": {
        "type": "http",
        "scheme": "basic"
      },
      "petstore_auth": {
        "type": "oauth2",
        "flows": {
          "authorizationCode": {
            "scopes": {
              "write:pets": "modify pets in your account",
              "read:pets": "read your pets"
            },
            "authorizationUrl": "https://example.org/api/oauth/dialog",
            "tokenUrl": "https://example.org/api/oauth/token"
          }
        }
      }
    }
  }
}

참조