-
Notifications
You must be signed in to change notification settings - Fork 51
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] revisit tcgc method and operation design #2295
Comments
First step let's see how we should deal with the responses. For current TCGC implementation, the type property of both method level Then for situation that user does not specify the response wrapper, current implementation follows the rule of "generate method as TypeSpec method". Only for some cases, the HTTP payload type should be different from user defined type, current implementation seems not so correct. See cases. Case1: user uses implicit body, but body model has no metadata property, and all properties has no non-read visibility (most common case), TCGC response type property is model
Case2: user uses explicit
Case 3: user uses implicit body, and the body model has either
For situation that user does specify the response wrapper with HTTP header or HTTP response status code, current implementation does not follow the rule of "generate method as TypeSpec method". The method level response type is always the HTTP payload body type. The original thinking is most languages does not export response envelop for customer. See cases. Case 1: user uses all explicit definition for response. This always happen for template cases. TCGC response type property is model
Case 2: user define the response with intersection or spread. This also always happen for template cases. For current TCGC implementation, it tries to get back the original user defined type. So, TCGC response type property is model
|
@Azure/dpg-devs @Azure/dpg-owners please share your thoughts. |
Yeah, at current design, Java does not use the response envelop (combine body and header) as response model in API (the only exception could be HEAD http method, where http headers is the only data). For case 2 of For case 3, we shall see how language handles the response envelop (class, or not). I think TCGC can return different model in SDK method response and service method response, but the difficulty is the naming (we probably don't want both model takes same name, but we also want emitter able to get a proper name if they only choose one model). |
Since Timothee has clarified, Below are my own understandings, we do not have solid designs for these yet. But these are the results that I think reasonable following the principle above.
The second part cases:
|
many languages have concern about the relationship of method and operation in tcgc. also, we have concern about how we should honor (only see raw typespec or include some of the protocol info) for tcgc method level signature. and, current tcgc's method has inconsistency of parameters and responses. parameters are convenience level, but responses are protocol level. we should at lease either consider to make it consistent or switch to a middle line that emitter is easy to use. let's use this issue to start discussion.
The text was updated successfully, but these errors were encountered: