설명
최상위와 작업 양쪽에 security가 없으면 명세상 해당 작업에는 인증 요구사항이 없습니다. 의도적으로 공개한 작업은 이대로 둘 수 있습니다.
잠재적 영향
보호된 작업이라도 생성된 클라이언트가 인증 정보를 빼고 요청하여 서버에서 거부될 수 있습니다.
해결 방법
보호할 작업에서 서버의 인증 방식을 참조하세요. 여러 작업이 같은 방식을 쓰면 최상위 security에 한 번 지정하세요.
예시
예시에는 exampleSecurity가 이미 정의되어 있습니다. 전역 security에 이 이름을 추가하면 GET /에도 X-API-Key 헤더가 필요합니다.
변경 전
json
{
"openapi": "3.0.0",
"info": {
"title": "Simple API overview",
"version": "1.0.0"
},
"paths": {
"/": {
"get": {
"responses": {
"200": {
"description": "ok"
}
}
}
}
},
"components": {
"securitySchemes": {
"exampleSecurity": {
"type": "apiKey",
"in": "header",
"name": "X-API-Key"
}
}
}
}
변경 후
json
{
"openapi": "3.0.0",
"info": {
"title": "Simple API overview",
"version": "1.0.0"
},
"paths": {
"/": {
"get": {
"responses": {
"200": {
"description": "ok"
}
}
}
}
},
"security": [
{
"exampleSecurity": []
}
],
"components": {
"securitySchemes": {
"exampleSecurity": {
"type": "apiKey",
"in": "header",
"name": "X-API-Key"
}
}
}
}