Skip to content

Fix: Exclude required headerCollectionPrefix params from operation signature and respect generate options#3845

Open
joheredi wants to merge 3 commits intoAzure:mainfrom
joheredi:fix/header-collection-prefix-required-signature
Open

Fix: Exclude required headerCollectionPrefix params from operation signature and respect generate options#3845
joheredi wants to merge 3 commits intoAzure:mainfrom
joheredi:fix/header-collection-prefix-required-signature

Conversation

@joheredi
Copy link
Member

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 with headerCollectionPrefix.

Fix: Added a single filter condition in getOperationSignatureParameters():

getClientOptions(p, "headerCollectionPrefix") === undefined

This works because SdkMethodParameter extends DecoratedType, so getClientOptions() can read the @clientOption decorator directly from the method parameter.

2. Respect generateTest and generateMetadata options

  • Guard snippets.spec.ts generation with option.generateTest !== false so test files are not emitted when tests are disabled.
  • Guard metadata.json emission with option.generateMetadata !== false so metadata is not emitted when explicitly opted out.

Testing

  • Added new unit test scenario: headerCollectionPrefixRequiredSkipSignature.md — verifies a required metadata header with headerCollectionPrefix is excluded from both the send function and public operation signatures.
  • All 581 existing unit tests pass.

…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>
joheredi and others added 2 commits March 16, 2026 21:03
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>
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