Add support for empty Security Requirement Object (`{}`) in security requirement
- Dominant language
- PHP
- Stars
- 500
- Forks
- 99
- PR merge metrics
- No merged PRs in 30d
Description
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

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/
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in spec/SecurityRequirements.php, where the reported Undefined offset occurs, and review tests/IssueTest.php, including test224FailsOnLargeDefinitions. Reproduce the Cloudflare OpenAPI case and confirm that an empty Security Requirement Object is accepted without the reported error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- api, security
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100