Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TCGC] [Bug] TCGC should return usage as 0 for model when it is only used in protocol method's response body #1748

Closed
Tracked by #2931
haolingdong-msft opened this issue Oct 28, 2024 · 0 comments
Assignees
Labels
lib:tcgc Issues for @azure-tools/typespec-client-generator-core library

Comments

@haolingdong-msft
Copy link
Member

Issue

When a model is only used in protocol method's response body. TCGC returns the model usage as 256, not 0.
For example, for below case, ResourceD is only used in protocol method's response body, but its usage is 256. While ResourceC which is only used in protocol method's request body, its usage is 0. I think ResourceC's usage is correct, but ResourceD's usage is wrong.

  @doc("When set protocol true and convenient false, only the protocol method should be generated, ResourceC and ResourceD should not be generated")
  @route("onlyProtocol")
  @post
  @convenientAPI(false)
  @protocolAPI(true)
  onlyProtocol(@body body: ResourceC): ResourceD;

detailed test case

Image

Solution

When a model is used in protocol method's response body, TCGC returns the usage as 0 no matter it's input or output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lib:tcgc Issues for @azure-tools/typespec-client-generator-core library
Projects
None yet
Development

No branches or pull requests

2 participants