-
Notifications
You must be signed in to change notification settings - Fork 37
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] - use original model for simple spread instead of creating a new anonymous model #1132
Comments
could you clarify the source meaning? for example, if anonymous model is in parameter, what should the source model be? other cases are model property, return type, etc. |
@ArcturusZhang has the following comment: For this typespec:
the TCGC result gives us a We agree that there are cases that returning the original model is not possible, such as an operation with spread of two different models, in those cases, we could still do the |
@joheredi could you confirm if it is enough for js? |
Yes I think this would be good enough |
use original model for body parameter in `SdkServiceOperation` if it is from a simple spread. simple spread means spread model without any `@header`, `@query` or `@path` property and the spread model is the only source of http body. examples, `op test(...Model): void;` `op test(@Header h: string, @query q: string, ...Model): void;` these two operation will have `Model` as body parameter. ``` op test(...A): void; model A { @query q: string; prop: string; } ``` this operation will have an anonymous model with only `prop` property and generated name `TestRequest` as body parameter. resolve: #1132 cc: @ArcturusZhang @joheredi --------- Co-authored-by: Dapeng Zhang <[email protected]>
Clear and concise description of the problem
There are scenarios where tracking the source model of anonymous models is beneficial. For instance, in TypeScript code generation, this feature would enable us to map serializer/deserializer types between RLC (Rest Level Client) and Modular. This functionality is crucial for bridging gaps between RLC and Modular types.
Example
Consider the following TypeSpec model:
With the ability to track the source model, we could implement the following TypeScript code:
Here, BarModel is generated from TCGC, but there is no equivalent interface in RLC as it doesn't generate anonymous models.
Checklist
The text was updated successfully, but these errors were encountered: