-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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]>
- Loading branch information
1 parent
88ba7bf
commit 56a4f7a
Showing
12 changed files
with
675 additions
and
259 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
changeKind: breaking | ||
packages: | ||
- "@azure-tools/typespec-client-generator-core" | ||
--- | ||
|
||
always spread models and aliases with `...` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.