Add PHP QueryParameter import after property renaming#7989
Open
AayushP123 wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a PHP generation bug where the @QueryParameter("...") docblock annotation could be emitted without importing Microsoft\Kiota\Abstractions\QueryParameter when query parameter property names are normalized (e.g., snake_case → camelCase). It adjusts the PHP refiner’s import evaluation order so the import decision occurs after SerializationName is populated, and adds a regression test for the scenario reported in #7602.
Changes:
- Run an additional PHP default-import evaluation pass specifically for
QueryParameterafterReplacePropertyNameshas setSerializationName. - Refactor the
QueryParameterimport evaluator into a dedicated evaluator list to ensure it’s applied at the correct stage. - Add a regression test validating both the renaming (
category_id→categoryId) and the presence of theQueryParameterimport.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/Kiota.Builder/Refiners/PhpRefiner.cs |
Ensures QueryParameter import is added after query-parameter property renaming populates SerializationName. |
tests/Kiota.Builder.Tests/Refiners/PhpLanguageRefinerTests.cs |
Adds regression coverage for snake_case query parameters retaining correct serialization name and import. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Evaluates the PHP
QueryParameterimport after query property names are normalized. Adds regression coverage for snake_case query parameters that become camelCase while retaining their serialization name.The import evaluator previously ran before
ReplacePropertyNamespopulatedSerializationName, so generated annotations could be emitted without the corresponding import.Validation
dotnet test tests/Kiota.Builder.Tests/Kiota.Builder.Tests.csproj --no-restore --nologo --filter 'FullyQualifiedName~Refiners.PhpLanguageRefinerTests'(14 passed)Fixes #7602