-
Notifications
You must be signed in to change notification settings - Fork 230
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
Provide a way to know which model one property is spread from #1516
Comments
Another special case is spreading a model with multiple target (as following) as parameter.
expected to generate client library:
The cadl compile parse this operation with one path parameter So we need to know that the three property |
There is also a |
@nguerrera I have one follow-up question, do you think the return value of
|
Case 2 is not currently valid. There must be an identifier to the right of The purpose of an alias is to give a Cadl dev-time only name to something that gets erased when we produce the type graph that emitters process. So there is not a way to get the name |
Case 2 actually is to spread an anonymous model. |
Case 2 won't parse. If we ever did allow case 2 to parse and gave it meaning, then it would become equivalent to Case 1 as that is the only sensible meaning. Case 1 spreads an anonymous model. The alias name is not a model name. getEffectiveModelType will never find an alias name. It uses the type graph from which all alias names have been erased. In general, the design is that alias names should never survive into emitter output. |
In CADL, the spread alias/model will act as operation parameter. CodeGen should flattern parameters defined with alias in CADL.
It will contain following scenario:
We need to generate code:
When cadl compler parse above operations (
spreadWithModel
andsperadWithAlias
), it will directly spread the model and provide an anomous model with the two propertiesname
andage
as body type. In that way, it looses the information that the two properties are spread from modelFoo
.We need to know that the
name
andage
are spread by modelFoo
, and then use the model Foo as the operation parameter.Can cadl provide an api like getSpreadSource(ModelProperty) or metadata in the ModelProperty to identify which model the property is spread from?
The text was updated successfully, but these errors were encountered: