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] How to generate code with nested properties mappings between sdk method and sdk operation parameters? #2131

Open
MaryGao opened this issue Jan 26, 2025 · 1 comment
Labels
lib:tcgc Issues for @azure-tools/typespec-client-generator-core library

Comments

@MaryGao
Copy link
Member

MaryGao commented Jan 26, 2025

This is a case we met recently and for template ArmResourceActionAsync its second parameter is marked as bodyRoot.

With below case1 we have required body parameter which is marked as @bodyRoot and also two optional parameters which is marked as @body and @query. In tcgc it would give one method parameter with body. And for operation parameters its correspondingMethodParams would not directly link to top-level body but its properties bodyParam and queryParam.

I have following things to confirm:

  • How should we interprect @bodyRoot here?
  • Can we(emitter) just take@bodyRoot as a wrapper object and won't impact the method signiture?
  • So case 1 and case 2 are the same? If so, can tcgc produce the same codemodel?
  • Does the parameter order matter?

Case1

op read(@bodyRoot body: {
  @body bodyParam?: string;
  @query queryParam?: string;
}): void;

Case2

op read(@body bodyParam?: string, @query queryParam?: string;): void;

Case3

op read(bodyParam?: string, @query queryParam?: string;): void;

Case4

op read(@bodyRoot body: {
  bodyParam1?: string;
  bodyParam2?: string;
  @query queryParam?: string;
}): void;
@MaryGao MaryGao changed the title [tcgc] How to get correct correspondingMethodParams with nested properties? [tcgc] How to generate code with nested properties mappings between sdk method and sdk operation parameters? Jan 26, 2025
@qiaozha
Copy link
Member

qiaozha commented Jan 26, 2025

Is this duplicate with this one microsoft/typespec#4815 ?

@lirenhe lirenhe added the lib:tcgc Issues for @azure-tools/typespec-client-generator-core library label Jan 27, 2025
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

3 participants