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

[Bug]: TCGC SDK method parameter is in-consistant with operation parameters with autoRouted constant path params #1728

Closed
4 tasks done
MaryGao opened this issue Oct 23, 2024 · 1 comment
Assignees
Labels
bug Something isn't working lib:tcgc Issues for @azure-tools/typespec-client-generator-core library

Comments

@MaryGao
Copy link
Member

MaryGao commented Oct 23, 2024

Describe the bug

SDK method parameter is in-consistant with operation parameters with constant path params.

With below typespec example

@doc("show example demo")
@autoRoute
op read(@path param: "foo/bar"): void;

SDK method would have param parameter as constand type.
Image

But relevant operation has 0 parameter. And there is no parameter in path /foo/bar.

Image

After invetigation it is because the autoRoute feature do the replacement between the param and relevant value if it is string literal - https://github.com/microsoft/typespec/blob/main/packages/rest/src/rest.ts#L138-L143.

I think it's better to align the parameters between method and operation.

Reproduction

NA

Checklist

  • Follow our Code of Conduct
  • Check that this issue is about the Azure libraries for typespec. For bug in the typespec language or core libraries file it in the TypeSpec repo
  • Check that there isn't already an issue that request the same bug to avoid creating a duplicate.
  • The provided reproduction is a minimal reproducible example of the bug.
@MaryGao MaryGao added the bug Something isn't working label Oct 23, 2024
@MaryGao MaryGao changed the title [tcgc]: SDK method parameter is in-consistant with operation parameters with constant path params [Bug]: TCGC SDK method parameter is in-consistant with operation parameters with autoRouted constant path params Oct 23, 2024
@MaryGao MaryGao added the lib:tcgc Issues for @azure-tools/typespec-client-generator-core library label Oct 23, 2024
@MaryGao
Copy link
Member Author

MaryGao commented Oct 23, 2024

I want to leverage this issue to discuss the design for method vs operation.

  • it seems we have two different layers to duplicate things, why that?
  • the in-consistancy would happen in parameters e.g spreading or above case
  • the in-consistancy would happen in responses because of body or bodyRoot decorator
  • what is the usage in getAllModels e.g op test(@bodyRoot body: {@body body: Test}): void;(how to interpret body in bodyRoot microsoft/typespec#4815)

@MaryGao MaryGao added lib:azure-resource-manager Issues for @azure-tools/typespec-azure-core library lib:tcgc Issues for @azure-tools/typespec-client-generator-core library and removed lib:tcgc Issues for @azure-tools/typespec-client-generator-core library lib:azure-resource-manager Issues for @azure-tools/typespec-azure-core library labels Oct 24, 2024
@tadelesh tadelesh closed this as completed Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working lib:tcgc Issues for @azure-tools/typespec-client-generator-core library
Projects
None yet
Development

No branches or pull requests

2 participants