Skip to content

Conversation

@v-jiaodi
Copy link
Member

fixes #3610

@v-jiaodi v-jiaodi marked this pull request as ready for review November 28, 2025 01:43
@qiaozha qiaozha added the p0 priority 0 label Dec 3, 2025
{
onClientOnly: true
onClientOnly: true,
requiredOnly: true
Copy link
Member

Choose a reason for hiding this comment

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

We should not filter out the optional client params at the begining and we should handle optional client params during constructing the statement.

Copy link
Member

@MaryGao MaryGao left a comment

Choose a reason for hiding this comment

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

We should not filter out the optional client params at the begining and we should handle optional client params during constructing the statement.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes issue #3610 by preventing optional client-level parameters from appearing as standalone parameters in generated sample code. The fix ensures that when client parameters have default values (making them optional), they are not included in the client constructor call in samples.

Key changes:

  • Added requiredOnly: true option when retrieving client parameters for sample generation
  • Added a comprehensive unit test case demonstrating the expected behavior for optional parameters

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
packages/typespec-ts/src/modular/emitSamples.ts Added requiredOnly: true option to filter out optional client-level parameters when preparing example parameters for sample generation
packages/typespec-ts/test/modularUnit/scenarios/samples/parameters/optionalParameter.md Added new test case validating that optional client parameters (like endpoint with default value) and optional operation parameters are handled correctly in generated samples

@qiaozha qiaozha added P1 priority 1 and removed p0 priority 0 labels Dec 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P1 priority 1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[sample gen] Optional parameters are not being filtered out when generating sample code.

3 participants