Skip to content

fix(php-symfony): enum $ref query params — short types and imports (#23521)#23525

Merged
wing328 merged 2 commits intoOpenAPITools:masterfrom
JerrySLau:fix_php_symfony_isenumref_fqcn
Apr 14, 2026
Merged

fix(php-symfony): enum $ref query params — short types and imports (#23521)#23525
wing328 merged 2 commits intoOpenAPITools:masterfrom
JerrySLau:fix_php_symfony_isenumref_fqcn

Conversation

@JerrySLau
Copy link
Copy Markdown
Contributor

@JerrySLau JerrySLau commented Apr 13, 2026

fixes #23521

Summary

php-symfony: fix enum-by-reference query parameters (components.parameters → schema $ref to string enum) so DefaultApiInterface uses short class names and use imports that match the generated model, instead of stitched / double-modelPackage type strings.

See #23521 (wrong FQCN / import for $ref enum query params in DefaultApiInterface).

Changes

  • PhpSymfonyServerCodegen: normalizeEnumRefParameterDataTypesyncEnumRefOperationImports → after all operations, refreshAggregatedImportsForOperations so dataType is the short PHP model name and OperationsMap imports match Mustache.
  • api.mustache: parameter PHPDoc and signatures use vendorExtensions.x-parameter-type for all params (including isEnumRef); enum refs get x-parameter-type via getTypeHint(modelPackage + "\\" + dataType, false) when needed.
  • Tests: modules/openapi-generator/src/test/resources/3_1/php-symfony/petstore-dotted-enum-ref-query-param-component.yaml + PhpSymfonyServerCodegenTest (short use, short type hint, @param shape; when php is on PATH, php -l on generated DefaultApiInterface.php).
  • Docs: Javadoc on the enum-ref import pipeline; loop / call comments in postProcessOperationsWithModels.

How to validate

./mvnw -pl modules/openapi-generator test -Dtest=PhpSymfonyServerCodegenTest
./mvnw -pl modules/openapi-generator test -Dtest='org.openapitools.codegen.php.**'
# optional:
./bin/generate-samples.sh bin/configs/php-symfony.yaml

Build / samples / docs (per contribution checklist)

Local run with Java 11 (JAVA_HOME=/opt/homebrew/opt/openjdk@11/libexec/openjdk.jdk/Contents/Home, OpenJDK 11.0.30):

export JAVA_HOME="/opt/homebrew/opt/openjdk@11/libexec/openjdk.jdk/Contents/Home"
export PATH="$JAVA_HOME/bin:$PATH"
./mvnw clean package || exit
./bin/generate-samples.sh ./bin/configs/*.yaml || exit
./bin/utils/export_docs_generators.sh || exit

All three commands completed successfully; sample batch reported 741 configs successful. All generated / updated files from these commands are included in this PR.

cc PHP committee: @jebentier @dkarlovi @mandrean @jfastnacht @ackintosh @ybelenko @renepardon

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in WSL)
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • File the PR against the correct branch: master (upcoming 7.x.0 minor release — breaking changes with fallbacks). (If you opened against 8.0.x instead, edit this line accordingly.)
  • If your PR solves a reported issue, reference it using GitHub's linking syntax (e.g., having "fixes #123" present in the PR description)
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

Summary by cubic

Fixes #23521. Corrects enum-by-reference query params in php-symfony so DefaultApiInterface uses short enum class names with proper use imports, avoiding stitched or flattened modelPackage tokens.

  • Bug Fixes
    • Normalize isEnumRef param dataType to the short model class and resync per-operation imports; rebuild aggregated imports for accurate use lines.
    • Unify api.mustache to use vendorExtensions.x-parameter-type for all params so type hints and @param use the short enum name.
    • Adjust api_controller.mustache and api_input_validation.mustache to build FQCNs as \{modelPackage}\{dataType} with correct escaping.
    • Add OAS 3.1 test with dotted keys to verify short use import, short type hint in DefaultApiInterface, and php -l passes.

Written for commit 8def2cb. Summary will update on new commits.

…imports

* Normalize dotted / flattened enum-ref dataType and resync operation imports;
  rebuild OperationsMap imports after postProcess for api.mustache use lines
* Unify api.mustache @param and signatures on vendorExtensions.x-parameter-type
  (short name + optional|null) for isEnumRef
* Add OAS 3.1 petstore fixture under 3_1/php-symfony and extend
  PhpSymfonyServerCodegenTest (PHPDoc + php -l)
* Document normalizeEnumRefParameterDataType / sync / refresh import pipeline
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 6 files

@wing328 wing328 added this to the 7.22.0 milestone Apr 14, 2026
@wing328 wing328 merged commit ed72281 into OpenAPITools:master Apr 14, 2026
15 checks passed
@wing328
Copy link
Copy Markdown
Member

wing328 commented Apr 14, 2026

thanks for the PR which has been merged

@JerrySLau
Copy link
Copy Markdown
Contributor Author

不谢

我在使用中还发现了几个关于 enum 的问题和关于 Controller 代码生成的问题

后续再提 PR

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.

[BUG][php-symfony] Wrong FQCN / use import for $ref enum query parameters in DefaultApiInterface (double modelPackage prefix)

2 participants