Skip to content

fix(openapi): throw clear error for openapi parameter missing name in yaml config#8297

Merged
soyuka merged 1 commit into
api-platform:4.3from
soyuka:fix/openapi-parameter-missing-name-8013
Jun 13, 2026
Merged

fix(openapi): throw clear error for openapi parameter missing name in yaml config#8297
soyuka merged 1 commit into
api-platform:4.3from
soyuka:fix/openapi-parameter-missing-name-8013

Conversation

@soyuka

@soyuka soyuka commented Jun 12, 2026

Copy link
Copy Markdown
Member

Summary

When a YAML/XML-configured operation declares an openapi.parameters entry without a name (or in), YamlResourceExtractor::buildOpenapi() accessed $parameter['name'] / $parameter['in'] unguarded. This emitted a Warning: Undefined array key "name" (the original symptom of #8013, surfaced via api:openapi:export) followed by a cryptic TypeError from the Parameter constructor.

name and in are required fields of an OpenAPI parameter object. The extractor now throws a clear InvalidArgumentException naming the missing required key, instead of leaking a PHP warning and producing broken output.

The original report used the removed 2.6 collectionOperations/openapi_context syntax (that array path is gone from OpenApiFactory), but the modern config equivalent (openapi.parameters arrays) reaches the same unguarded code in the extractor.

Reproduction

Declaring an operation openapi.parameters entry with no name key crashed with Undefined array key "name" + TypeError rather than a helpful error.

Test plan

  • Added testOpenApiParameterWithoutNameThrowsClearException (fails before fix, passes after).
  • YamlExtractorTest passes; php-cs-fixer + PHPStan clean.

Fixes #8013

… yaml config

YamlResourceExtractor accessed $parameter['name']/['in'] unguarded when building OpenAPI parameters from config, emitting an Undefined array key warning followed by a cryptic TypeError. It now throws an InvalidArgumentException naming the missing required key. name and in are required fields of an OpenAPI parameter object.

Fixes api-platform#8013
@soyuka soyuka merged commit 20baa61 into api-platform:4.3 Jun 13, 2026
110 of 112 checks passed
@soyuka soyuka deleted the fix/openapi-parameter-missing-name-8013 branch June 13, 2026 05:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant