cebe / cebe/php-openapi

CLI call to openapi-spec with security in path fails

Open
#242 6 comments 1 reaction 0 assignees View on GitHub
Dominant language
PHP
Stars
500
Forks
99
PR merge metrics
No merged PRs in 30d

Description

Type: Bug
Since: 1.8.0

Description:
The CLI call `php-openapi validate example.spec.json` fails due to the fact that the security in path is transformed to a list of arrays and not a list of objects in https://github.com/cebe/php-openapi/blob/893ab104be1f5dfe5a39766703f583584e43c6e1/src/spec/SecurityRequirements.php#L64

Minimal example.spec.json to reproduce:
```json
{
"openapi": "3.0.0",
"info": {
"title": "My API",
"version": "1, 2"
},
"paths": {
"/v1/users/profile": {
"get": {
"operationId": "V1GetUserProfile",
"summary": "Returns the user profile",
"responses": {
"200": {
"description": "dummy"
}
},
"security": [
{
"test_test": ["test:scope:foo"]
}
]
}
}
},
"components": {
"securitySchemes": {
"test_test": {
"type": "oauth2",
"flows": {
"authorizationCode": {
"authorizationUrl": "https://example.com/openid-connect/auth",
"tokenUrl": "https://example.com/openid-connect/token",
"scopes": {
"test:scope:foo": "test_scope"
}
}
}
}
}
}
}
```

I'll provide a MR with test case and a fix if you like.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at src/spec/SecurityRequirements.php around line 64 and reproduce the failure with the minimal example.spec.json from the issue using the php-openapi validate CLI command. Trace how the security requirement is transformed, then add the mentioned test case and verify that validation succeeds with the security entry represented correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, php
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.