Skip to content

refactor: align SwaggerService/SwaggerSpecValidator with open api 3.0 - #203

Merged
DenTray merged 18 commits into
masterfrom
201-align-openapi
Aug 31, 2026
Merged

DenTray merged 18 commits into
masterfrom
201-align-openapi

Conversation

@neellii

@neellii neellii commented Jun 3, 2026

Copy link
Copy Markdown

Description

Update OpenAPI security generation in src/Services/SwaggerService.php to align with OAS 3.1:

Move security definitions from legacy securityDefinitions to components.securitySchemes.
Remove Swagger 2.0 fallback logic. Support explicit auth token lookup by configured in value:
header
query
cookie
Remove obsolete TODO comment related to migration to Swagger 3.0.
Update validation in src/Validators/SwaggerSpecValidator.php:

Validate security schemes in the OAS 3 location: components.securitySchemes.
Allow cookie as a valid value for security scheme location (in).

references: https://swagger.io/specification/#security-scheme-object

Fixes #201

Type of change

  • Code refactoring

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3b46fc8bf8

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/Validators/SwaggerSpecValidator.php Outdated
$invalidValues = array_diff(Arr::wrap($data[$field]), $allowedValues);
$fields = Arr::wrap($data[$field]);

if (is_multidimensional($fields)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Avoid dev-only helper in runtime validator

When this package is installed without dev dependencies, ronasit/laravel-helpers is not installed because it is listed only under require-dev, so validating any document with a present optional value such as an operation schemes, parameter in, or security scheme flows will call an undefined global is_multidimensional() and fail with a fatal error instead of producing docs. Please replace this with local logic or move the helper package to runtime dependencies.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a6f8419b68

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/Validators/SwaggerSpecValidator.php Outdated
'security_definition_type' => ['basic', 'apiKey', 'oauth2'],
'security_schemes_flows' => ['implicit', 'password', 'clientCredentials', 'authorizationCode'],
'security_schemes_in' => ['query', 'header', 'cookie'],
'security_schemes_type' => ['apiKey', 'http', 'mutualTLS', 'oauth2', 'openIdConnect'],

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Only allow security types the generator can emit

Adding http, mutualTLS, oauth2, and openIdConnect here makes those OpenAPI 3 security schemes pass validation, but SwaggerService::generateSecuritySchemesObject() still emits only type, name, and in. When a project configures a newly allowed scheme such as HTTP bearer (type: http, scheme: bearer), the generated components.securitySchemes omits the required scheme field and tries to read nonexistent name/in config keys, so the package produces invalid docs or errors instead of usable authentication metadata.

Useful? React with 👍 / 👎.

@neellii neellii Jun 4, 2026 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DenTray the issue i am working on does not cover this case, but should we update generateSecuritySchemesObject method to support other security scheme types ?

         'apiKey' => [
            "type" => "apiKey", // required for all types
            "in" => "header", // required for type apiKey
            "name" => "X-API-Key", // required for type apiKey
            "description" => "some description" // optional for any type 
        ],
        'httpBasic' => [
            "type" => "http",
            "scheme" => "basic", // required for type http 
        ],
        'bearerAuth' => [
            'type' => 'http',
            'scheme' => 'bearer',
            'bearerFormat' => 'JWT', // optional for http bearer
        ],
        'oauth' => [
            'type' => 'oauth2',
            'flows' => [ // required for type oauth2
               'authorizationCode' => [
                    'authorizationUrl' => 'https://auth.example.com/authorize',
                    'tokenUrl' => 'https://auth.example.com/token',
                    'scopes' => [
                        'read' => 'read',
                        'write' => 'write',
                    ],
                ],
            ]
        ],
        'openId' => [
            'type' => 'openIdConnect',
            'openIdConnectUrl' => 'https://auth.example.com/openIdConnect', // required for type openIdConnect
        ],

ref: https://swagger.io/specification/#security-scheme-object

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@neellii I believe it makes sense.

It looks like security_drivers in the auto-doc.php config hasn't been updated to the new format, and it's used in the generateSecuritySchemesObject method.

Now jwt is a proper OAS 3.0 HTTP bearer scheme, and laravel uses the actual Laravel session cookie name.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8c180f0905

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/Validators/SwaggerSpecValidator.php Outdated
Comment on lines +409 to +410
if (!array_is_list($fields)) {
$fields = array_keys($fields);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Restrict associative-key validation to flows

When a validated field is an associative array, this now validates the array keys for every field, not just OAuth flows. In any generated or additional document where a scalar/list field is accidentally an object, e.g. a schema type of { "object": true } or a parameter in of { "query": true }, the key matches an allowed value and validation passes even though the OpenAPI field value is invalid, so getDocFileContent() can serve malformed specs instead of reporting the bad field.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an outdated note

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7efe9670ad

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

if (!empty($securityDefinitions)) {
$data['securityDefinitions'] = $securityDefinitions;
if (!empty($securitySchemes)) {
$data['components']['securitySchemes'] = $securitySchemes;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Migrate non-empty docs to securitySchemes

When $this->data is non-empty (for example an existing temp/production doc from before this change, or the still-present fixtures used by add-data tests), this new OAS3 location is never applied and the old root securityDefinitions is left in place. addData() then re-saves and serves a 3.1 document whose auth schemes are ignored by OpenAPI 3 tooling, so existing users can lose documented auth after upgrading unless the process data is normalized/migrated, not only freshly generated empty docs.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a separate architectural concern (temporary file reliability in crash scenarios) and is outside the scope of this security-related change.

@neellii
neellii requested a review from vitgrams June 8, 2026 06:16
Comment thread src/Validators/SwaggerSpecValidator.php Resolved
Comment thread src/Validators/SwaggerSpecValidator.php Resolved
Comment thread src/Validators/SwaggerSpecValidator.php Resolved
Comment thread src/Validators/SwaggerSpecValidator.php Outdated
'security_definition_type' => ['basic', 'apiKey', 'oauth2'],
'security_schemes_flows' => ['implicit', 'password', 'clientCredentials', 'authorizationCode'],
'security_schemes_in' => ['query', 'header', 'cookie'],
'security_schemes_type' => ['apiKey', 'http', 'mutualTLS', 'oauth2', 'openIdConnect'],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@neellii I believe it makes sense.

It looks like security_drivers in the auto-doc.php config hasn't been updated to the new format, and it's used in the generateSecuritySchemesObject method.

Now jwt is a proper OAS 3.0 HTTP bearer scheme, and laravel uses the actual Laravel session cookie name.

Comment thread src/Services/SwaggerService.php Resolved
@vitgrams vitgrams assigned neellii and unassigned vitgrams Jun 11, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f02391de02

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

$this->validateFieldValue($securityDefinition, 'flow', self::ALLOWED_VALUES['security_definition_flow'], $parentId);
$this->validateFieldValue($securityScheme, 'type', self::ALLOWED_VALUES['security_schemes_type'], $schemeId);
$this->validateFieldValue($securityScheme, 'in', self::ALLOWED_VALUES['security_schemes_in'], $schemeId);
$this->validateFieldValue($securityScheme, 'flows', self::ALLOWED_VALUES['security_schemes_flows'], $schemeId, true);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Validate OAuth flow objects before accepting them

When an additional or persisted document defines an OAuth2 security scheme with an allowed flow key but omits that flow's required fields, e.g. flows.authorizationCode without authorizationUrl, tokenUrl, or scopes, this only checks the flow name and validation succeeds. getDocFileContent() can then serve a malformed OpenAPI 3 document instead of reporting the invalid security scheme, so incomplete OAuth configs are silently accepted.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably isn't worth addressing in this MR, since these values are not used directly by SwaggerService.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7f76954029

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/Services/SwaggerService.php Outdated
}

return !empty($securityToken);
return $this->request->hasHeader('authorization');

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Guard the authorization fallback when security is disabled

When auto-doc.security is left empty (the default), $securityDriver is null, so this new non-apiKey fallback treats any request with an Authorization header as secured and addSecurityToOperation() writes an empty scheme name ("" => []) into the operation. Projects that intentionally disable security but still send auth headers during tests will get malformed/misleading OpenAPI output referencing a non-existent security scheme; return false before this header check when no security driver is configured.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like already fixed issue :

    return !empty($security) && $this->request->hasHeader('authorization');

Comment thread src/Validators/SwaggerSpecValidator.php Outdated
$this->validateFieldValue($securityDefinition, 'in', self::ALLOWED_VALUES['security_definition_in'], $parentId);
$this->validateFieldValue($securityDefinition, 'flow', self::ALLOWED_VALUES['security_definition_flow'], $parentId);
$this->validateFieldValue($securityScheme, 'type', self::ALLOWED_VALUES['security_schemes_type'], $schemeId);
$this->validateFieldsPresent($securityScheme, self::REQUIRED_FIELDS['securitySchemesByType'][$securityScheme['type']], $schemeId);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Add required-field handling for mutualTLS

When a valid OAS 3 security scheme uses type: mutualTLS, the new allowed-types list accepts it, but this lookup has no corresponding securitySchemesByType['mutualTLS'] entry, so validation raises an undefined-key/type error and getDocFileContent() returns an error document instead of accepting the spec. Add an empty required-fields entry or skip the type-specific lookup for schemes with no additional required fields; the fresh evidence is that mutualTLS is allowed while this map still omits it.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1e92a3cf94

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/Services/SwaggerService.php Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ead36f086c

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/Services/SwaggerService.php Resolved
@neellii neellii assigned vitgrams and unassigned neellii Jun 16, 2026
Comment thread src/Validators/SwaggerSpecValidator.php Resolved
@vitgrams vitgrams assigned neellii and unassigned vitgrams Jun 21, 2026
@neellii neellii assigned vitgrams and unassigned neellii Jun 22, 2026
Comment thread config/auto-doc.php
'laravel_session' => [
'type' => 'apiKey',
'name' => '__ym_uid',
'name' => 'laravel_session',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DenTray
It looks like previously, for some reason, a hardcoded Yandex Metrics value was used for the Laravel session here.

You can either use something more realistic, like:

'name' => env('SESSION_COOKIE', Str::slug((string) env('APP_NAME', 'laravel'), '_') . '_session'),

or just keep laravel_session as it is now.

Comment thread src/Services/SwaggerService.php Outdated
$securityDriver = Arr::get($this->config, "security_drivers.{$security}");

return match ($securityDriver['type']) {
'apiKey' => !empty(match ($securityDriver['in']) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'apiKey' => !empty(match ($securityDriver['in']) {
'apiKey' => (!empty(match ($securityDriver['in'])) {

Comment thread src/Services/SwaggerService.php Outdated
Comment on lines +771 to +777
return match ($securityDriver['type']) {
'apiKey' => !empty(match ($securityDriver['in']) {
'header' => $this->request->header($securityDriver['name']),
'query' => $this->request->query($securityDriver['name']),
'cookie' => $this->request->cookie($securityDriver['name']),
default => null,
}),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing keys in a driver config crash the generation with a raw PHP warning instead of a config exception. Verified locally: a driver without type throws ErrorException: Undefined array key "type", and type: apiKey without in throws Undefined array key "in". initConfig() only checks that the driver key exists, not its shape.

Suggested change
return match ($securityDriver['type']) {
'apiKey' => !empty(match ($securityDriver['in']) {
'header' => $this->request->header($securityDriver['name']),
'query' => $this->request->query($securityDriver['name']),
'cookie' => $this->request->cookie($securityDriver['name']),
default => null,
}),
return match (Arr::get($securityDriver, 'type')) {
'apiKey' => !empty(match (Arr::get($securityDriver, 'in')) {
'header' => $this->request->header($securityDriver['name']),
'query' => $this->request->query($securityDriver['name']),
'cookie' => $this->request->cookie($securityDriver['name']),
default => null,
}),

Comment thread src/Services/SwaggerService.php Outdated
default => null,
}),
'mutualTLS' => false,
default => $this->request->hasHeader('authorization'),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hasHeader() returns true for an empty Authorization: header, so an operation gets marked as secured without a token. Verified locally. The apiKey branch above uses !empty(), let's keep it consistent.

Suggested change
default => $this->request->hasHeader('authorization'),
default => !empty($this->request->header('authorization')),

@@ -770,26 +761,23 @@ protected function getSummary($request, array $annotations)
protected function requestSupportAuth(): bool

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

requestSupportAuth() is the core of this change, but it has no test coverage at all: no test passes a request carrying an auth token (generateGetRolesRequest() only sets Content-type), so security is [] in every fixture and both saveSecurity() and addSecurityToOperation() are never exercised. Please add a data-provider driven test covering apiKey+header, apiKey+query, apiKey+cookie, http (bearer) and mutualTLS, asserting the operation-level security block. getBaseRequest() in tests/TestCase.php:185 will need a cookies argument for the cookie case.

Comment thread tests/SwaggerServiceTest.php Outdated
'requestFixture' => 'tmp_data_search_roles_request_query_security',
],
[
'security' => 'header',

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new header case doesn't add coverage. After the SwaggerServiceMockTrait change the components.securitySchemes block is fed into the driver mock as input and simply echoed back in the assertion, so generateSecuritySchemes() isn't involved in this test at all - getAddEmptyData is what actually covers it. Behaviour-wise this case is identical to the query one (security: [] in both). Either drop it, or turn it into a real requestSupportAuth test (see the separate comment).

}
},
"securitySchemes": {
"query": {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scheme key is query, but the test runs with security = 'header' - it should be header. It passes only because this block is echoed back from the mock rather than generated. Same mismatch in the sibling fixtures: tmp_data_search_roles_request_query_security.json has "name": "authorization" while the test config declares 'query' => ['name' => 'api_key'], and tmp_data_search_roles_request_laravel_security.json has {"name": "Cookie", "in": "header"} while the config declares ['name' => 'laravel', 'in' => 'cookie'].

'tag' => ['name'],
];

public const SECURITY_SCHEMES_REQUIRED_FIELDS_BY_TYPE = [

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only the apiKey entry of SECURITY_SCHEMES_REQUIRED_FIELDS_BY_TYPE is covered by a test. Please add cases for the remaining three: http without scheme, oauth2 without flows, openIdConnect without openIdConnectUrl.

Comment thread src/Validators/SwaggerSpecValidator.php Outdated
'security_definition_type' => ['basic', 'apiKey', 'oauth2'],
'security_schemes_flows' => ['implicit', 'password', 'clientCredentials', 'authorizationCode'],
'security_schemes_in' => ['query', 'header', 'cookie'],
'security_schemes_type' => ['apiKey', 'http', 'mutualTLS', 'oauth2', 'openIdConnect'],

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double space after 'http',.

Suggested change
'security_schemes_type' => ['apiKey', 'http', 'mutualTLS', 'oauth2', 'openIdConnect'],
'security_schemes_type' => ['apiKey', 'http', 'mutualTLS', 'oauth2', 'openIdConnect'],

- read the security driver `type` and `in` keys via `Arr::get` to avoid
  undefined array key errors on malformed driver configs
- treat an empty `Authorization` header as unauthorized, consistently
  with the `apiKey` branch
- remove the double space in the security scheme type list
- cover `requestSupportAuth` with tests for the `apiKey` header, query
  and cookie locations, `http` and `mutualTLS` drivers, and malformed
  driver configs
- support cookies and extra query data in the request test helpers
- drop the redundant `header` case from `addDataWithSecurity`, which
  echoed the fixture back instead of exercising the generation
- align the `laravel` and `query` security fixtures with the config
  declared by the test
- cover the required fields of the `http`, `oauth2` and `openIdConnect`
  security scheme types

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5d0145a4d2

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

$schemeId = "components.securitySchemes.{$index}";

$this->validateFieldsPresent($securityDefinition, self::REQUIRED_FIELDS['security_definition'], $parentId);
$this->validateFieldsPresent($securityScheme, self::REQUIRED_FIELDS['securitySchemes'], $schemeId);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Allow referenced security schemes

When components.securitySchemes contains a valid OpenAPI Reference Object, such as auth: {"$ref": "#/components/securitySchemes/bearer"}, this unconditional required-field check rejects it for lacking type before validateRefs() can validate the reference. This prevents getDocFileContent() from serving otherwise valid specs that reuse a local or external security scheme; skip object-level security-scheme validation when the entry is a Reference Object.

Useful? React with 👍 / 👎.

Comment thread src/Services/SwaggerService.php Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a462c71c2b

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/Services/SwaggerService.php Outdated
$securityDriver = Arr::get($this->config, "security_drivers.{$security}");

return match (Arr::get($securityDriver, 'type')) {
'apiKey' => (!empty(match (Arr::get($securityDriver, 'in'))) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P0 Badge Fix the malformed nested match expression

Under every configuration, this extra closing parenthesis terminates the nested match before its arm block, so PHP reports syntax error, unexpected token ")", expecting "{" while parsing SwaggerService.php. Because the class cannot be loaded at all, documentation generation fails before requestSupportAuth() can run.

Useful? React with 👍 / 👎.

DenTray and others added 2 commits August 31, 2026 17:56
Replace the nested `match` with a `getApiKeyToken` method, so the
remaining `match` only maps a security scheme type to the way its token
is looked up.

Return early when the driver declares no `name`: reading it via
`Arr::get` yields `null`, and `Request::header(null)` returns every
header, which would report any request as authorized.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
31.2% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@DenTray
DenTray merged commit c7097ae into master Aug 31, 2026
25 of 26 checks passed
@DenTray
DenTray deleted the 201-align-openapi branch August 31, 2026 12:04

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bf8d9b5af3

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread config/auto-doc.php
'laravel_session' => [
'type' => 'apiKey',
'name' => '__ym_uid',
'name' => 'laravel_session',

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Derive the Laravel session cookie name from configuration

When an application changes APP_NAME or explicitly configures session.cookie, Laravel's session cookie is not named laravel_session. Enabling this built-in driver then makes both the generated apiKey scheme and getApiKeyToken() look for the wrong cookie, so session-authenticated operations are left without a security requirement and Swagger clients send an unusable cookie. Use the application's configured session cookie name rather than this literal default.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Align OpenAPI security implementation with OAS 3.1 and clean up CI/test workflow

3 participants