Fix: Exclude required headerCollectionPrefix params from operation signature and respect generate options#3845
Open
joheredi wants to merge 3 commits intoAzure:mainfrom
Conversation
…gnature and respect generate options - Required header parameters decorated with @@clientoption("headerCollectionPrefix") were included in the operation method signature but never used in the operation body. Added a filter in getOperationSignatureParameters() to exclude them. - Guard snippets generation with generateTest !== false to skip test file generation when tests are disabled. - Guard metadata.json emission with generateMetadata !== false to skip metadata generation when explicitly opted out. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
metadata.json should not be controlled by the generate-metadata option since it contains essential build information (API versions, emitter version, cross-language definitions) that is always needed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
1. headerCollectionPrefix required parameter fix
Problem: When a required header parameter is decorated with
@@clientOption("headerCollectionPrefix", ...), it was incorrectly included as a positional parameter in the operation method signature. However, the serialization code in the operation body already correctly skips this parameter — resulting in a required parameter that is never used.Root Cause: In
getOperationSignatureParameters()(operationHelpers.ts), the filter that builds the method signature excluded constants, client params, cookies, and auto-generated headers — but did not exclude headers withheaderCollectionPrefix.Fix: Added a single filter condition in
getOperationSignatureParameters():This works because
SdkMethodParameterextendsDecoratedType, sogetClientOptions()can read the@clientOptiondecorator directly from the method parameter.2. Respect
generateTestandgenerateMetadataoptionssnippets.spec.tsgeneration withoption.generateTest !== falseso test files are not emitted when tests are disabled.metadata.jsonemission withoption.generateMetadata !== falseso metadata is not emitted when explicitly opted out.Testing
headerCollectionPrefixRequiredSkipSignature.md— verifies a requiredmetadataheader withheaderCollectionPrefixis excluded from both the send function and public operation signatures.