cebe / cebe/php-openapi

Add support for empty Security Requirement Object (`{}`) in security requirement

オープン
#238 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
PHP
スター
500
フォーク
99
PR マージ指標
30日以内にマージされた PR はありません

説明

From https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.4.md#security-requirement-object

An empty Security Requirement Object (`{}`) indicates anonymous access is supported.

This is used in https://raw.githubusercontent.com/cloudflare/api-schemas/refs/heads/main/openapi.yaml L164315

![Image](https://github.com/user-attachments/assets/233bc76b-28db-486f-b549-c4c929903e5e)

With current lib and above Cloudflare spec we get error:

```
There was 1 error:

1) IssueTest::test224FailsOnLargeDefinitions
Undefined offset: 0

/app/src/spec/SecurityRequirements.php:29
/app/src/SpecBaseObject.php:168
/app/src/SpecBaseObject.php:140
/app/src/SpecBaseObject.php:168
/app/src/SpecBaseObject.php:140
/app/src/spec/PathItem.php:81
/app/src/spec/Paths.php:62
/app/src/SpecBaseObject.php:168
/app/src/SpecBaseObject.php:140
/app/src/Reader.php:57
/app/src/Reader.php:138
/app/tests/IssueTest.php:17
phpvfscomposer:///app/vendor/phpunit/phpunit/phpunit:106

```

Observed this issue while fixing https://github.com/cebe/php-openapi/issues/224

So adding implementation for empty Security Requirement Object (`{}`) in security requirement is required.

More info about security schemes and security requirements can be obtained at https://swagger.io/docs/specification/v3_0/authentication/

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

報告された Undefined offset が発生する spec/SecurityRequirements.php から始め、test224FailsOnLargeDefinitions を含む tests/IssueTest.php を確認してください。Cloudflare OpenAPI のケースを再現し、空の Security Requirement Object が報告されたエラーなしで受け入れられることを確認してください。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
php
領域
api, security
issue の種類
バグ
難易度
2/5
見積もり時間
1〜3時間
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
55/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。