説明
操作に security: [] を指定すると、その操作には API 全体の認証要件が適用されません。公開する操作に使う設定です。
想定される影響
クライアントはこの操作を呼び出す際に認証情報を省略する場合があります。
対処方法
全体の要件を継承するには、操作の security フィールドを削除します。別の要件が必要な場合は操作に方式とスコープを指定し、サーバーのポリシーに合わせてください。
例
変更後の GET / は、全体の要件と同じ OAuth2 の read スコープを明示します。OAuth2 の URL はプロバイダーのエンドポイントに置き換えてください。
変更前
json
{
"openapi": "3.0.0",
"paths": {
"/": {
"get": {
"security": [],
"responses": {
"200": {
"description": "ok"
}
}
}
}
},
"security": [
{
"OAuth2": [
"read"
]
}
],
"info": {
"title": "Simple API overview",
"version": "1.0.0"
},
"components": {
"securitySchemes": {
"OAuth2": {
"type": "oauth2",
"flows": {
"authorizationCode": {
"authorizationUrl": "https://example.com/oauth/authorize",
"tokenUrl": "https://example.com/oauth/token",
"scopes": {
"read": "Read API versions"
}
}
}
}
}
}
}
変更後
json
{
"openapi": "3.0.0",
"paths": {
"/": {
"get": {
"security": [
{
"OAuth2": [
"read"
]
}
],
"responses": {
"200": {
"description": "ok"
}
}
}
}
},
"security": [
{
"OAuth2": [
"read"
]
}
],
"info": {
"title": "Simple API overview",
"version": "1.0.0"
},
"components": {
"securitySchemes": {
"OAuth2": {
"type": "oauth2",
"flows": {
"authorizationCode": {
"authorizationUrl": "https://example.com/oauth/authorize",
"tokenUrl": "https://example.com/oauth/token",
"scopes": {
"read": "Read API versions"
}
}
}
}
}
}
}