-
Notifications
You must be signed in to change notification settings - Fork 41
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] switch ...
to always mean spreading, regardless of model or alias
#772
Comments
iscai-msft
added
the
lib:tcgc
Issues for @azure-tools/typespec-client-generator-core library
label
May 2, 2024
closing because we're documenting this change in #1043 |
reopen since this is only for tcgc change. |
github-merge-queue bot
pushed a commit
that referenced
this issue
Jul 2, 2024
resolve: #772 several cases related with spread: 1. ``` op test(a: string, b: string, c: string): void; ``` 2. ``` model Test { prop: string } op test(...Test): void; ``` 3. ``` op test(@Body body: {prop: string}): void; ``` 4. ``` model Test { prop: string } op test(@Body body: {...Test}): void; ``` tcgc will do http body spread for 1 and 2, not for 3 and 4. and for http body model, 1, 2 will have a model `TestRequest` with spread usage and internal access. **Adoption guideline for emitters:** For emitters that have already adopted `getAllOperations`, if an operation has spread parameters: 1. The parameters of `SdkServiceMethod` are spread. 2. The body parameter of `SdkServiceOperation` is an anonymous model with `Usage.Spread` usage and `Access.Internal` access. And the `correspondingMethodParams` of the body will be list of the parameters of `SdkServiceMethod`. 3. Emitters could rely on the above info to generate clients' code. For emitters that have not adopted `getAllOperations`, emitters need to do: 1. Use `getHttpOperationWithCache` to prevent different body type resolving for spread cases. 2. Refer this code: https://github.com/Azure/typespec-azure/blob/5d77ba3e93521735a84051b4037c6f55e0a8a00a/packages/typespec-client-generator-core/src/types.ts#L1311-L1325 to change emitter's logic of handling operations with spread parameters. 3. When call `getClientType` from the body type of operation with spread, the return model will be an anonymous model with `Usage.Spread` usage and `Access.Internal` access. DO NOT CALL `getEffectivePayloadType` for body type if it is from spread. --------- Co-authored-by: iscai-msft <[email protected]> Co-authored-by: iscai-msft <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This issue is blocked by #771
Clear and concise description of the problem
Right now, tcgc has
...MyModel
maintain the logical grouping, but...MyAlias
spread out the parameters. This is because there is a lack of support forop(MyModel)
language definitions, and because we want to regroup models spread in azure core templates.However, this behavior is often confusing and has led to a lot of back and forth. After talking with the TypeSpec team, we want to change the default, because eventually with more language support,
...MyModel
should mean spread. The TypeSpec team will also modify the spreading currently done inAzure.Core
templates (#771). If we implement this change concurrently with theAzure.Core
changes, emitters shouldn't really see any code changesChecklist
The text was updated successfully, but these errors were encountered: