-
Notifications
You must be signed in to change notification settings - Fork 72
Open
Labels
lib:tcgcIssues for @azure-tools/typespec-client-generator-core libraryIssues for @azure-tools/typespec-client-generator-core library
Description
Related with this PR and this issue.
In TCGC, when there is no content type or accept parameter explicitly defined and request/response has body, TCGC will create synthetic parameters according to the rule:
- If the calculated request content types from HTTP lib is one value of
application/json,text/plain, andapplication/octet-stream, TCGC creates the content type parameter with type of constant, else, with type of string. It is to prevent a breaking change when a service adds more content types in the future. e.g. the service acceptingimage/pngat first and laterimage/jpeg, should not be a breaking change. - If the calculated response content types from HTTP lib is a single value, for accept, TCGC creates the accept parameter with type of constant, else, with type of string. The reason is it should be a breaking change to add a new response type. e.g. the service returns
image/pngat first and later provides the option to returnimage/jpeg.
The first question here is shall we follow above rule? Or TCGC just use the HTTP lib calculated content types to create the type.
The second question is with the new File body type (explicit/implicit content type in File templated parameter), shall we specific handle it or just follow above logic? And how to deal with */* for the no content type case in File?
op uploadFileSpecificContentType(@bodyRoot file: Http.File<"image/png">): NoContentResponse;
op downloadFileJsonContentType(): Http.File<"application/json">;
op downloadFileSpecificContentType(): Http.File<"image/png">;
op uploadFileMultipleContentTypes(
@bodyRoot file: Http.File<"image/png" | "image/jpeg">,
): NoContentResponse;
op downloadFileMultipleContentTypes(): Http.File<"image/png" | "image/jpeg">;
op uploadFileDefaultContentType(@bodyRoot file: Http.File): NoContentResponse; // will get `*/*` from HTTP lib
op downloadFileDefaultContentType(): Http.File; // will get `*/*` from HTTP lib
Reactions are currently unavailable
Metadata
Metadata
Labels
lib:tcgcIssues for @azure-tools/typespec-client-generator-core libraryIssues for @azure-tools/typespec-client-generator-core library