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

Remove alias model in getAllModels #300

Closed
tadelesh opened this issue Feb 23, 2024 · 5 comments
Closed

Remove alias model in getAllModels #300

tadelesh opened this issue Feb 23, 2024 · 5 comments
Assignees
Labels
feature New feature or request lib:tcgc Issues for @azure-tools/typespec-client-generator-core library

Comments

@tadelesh
Copy link
Member

We should not return alias for getAllModels. Current implementation could not distinguish between anonymous model and alias. Need to figure out the solution.

@tadelesh tadelesh added feature New feature or request lib:tcgc Issues for @azure-tools/typespec-client-generator-core library getAllModels labels Feb 23, 2024
@tadelesh tadelesh self-assigned this Feb 23, 2024
@tadelesh
Copy link
Member Author

tadelesh commented Feb 27, 2024

@iscai-msft @lmazuel @timotheeguerin
I don't know whether the following understanding for alias model is right. Alias model is actually a syntax helper for defining an anonymous model. Each time you use it, it will be a new anonymous model. For the following TypeSpec, two Test in body will be convert to two different anonymous models. So, getAllModels should also return two models with generated name.

alias Test = {
  name: string;
};

@route("/one")
@put
op one(@body body: Test): NoContentResponse;

@route("/two")
@put
op two(@body body: Test): NoContentResponse;

@timotheeguerin
Copy link
Member

Yeah nearly in that alias is not limited to models but any expression. It's just a way to provide a reusable expression that has not actual name in the type graph

@m-nash
Copy link
Member

m-nash commented Mar 7, 2024

@tadelesh can you help me understand why you need to distinguish between an anonymous model that was written inline vs an anonymous model that came from an alias. To me these don't have any unique behavior in a client library.

@tadelesh
Copy link
Member Author

tadelesh commented Mar 8, 2024

@tadelesh can you help me understand why you need to distinguish between an anonymous model that was written inline vs an anonymous model that came from an alias. To me these don't have any unique behavior in a client library.

@m-nash regarding the original goal to removing alias model from getAllModels, this is my question. But for now, I believe we do not need to specially handle the anonymous model from alias. It is just an anonymous model and we should return it from getAllModels as a normal model. I think this should be a non-issue.

@iscai-msft @lmazuel what do you think?

@timotheeguerin
Copy link
Member

yeah you shouldn't do any special handling for model coming from alias. Alias are a concept that is internal to the typespec compiler in a sense. It shouldn't have any mapping in emitters(Exception with a few that would want to show back the original syntax like ref doc generation or api view).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request lib:tcgc Issues for @azure-tools/typespec-client-generator-core library
Projects
None yet
Development

No branches or pull requests

3 participants