Skip to content

Fix to get right response and exception#2756

Merged
iscai-msft merged 18 commits intomainfrom
add-test
Aug 14, 2024
Merged

Fix to get right response and exception#2756
iscai-msft merged 18 commits intomainfrom
add-test

Conversation

@msyyc
Copy link
Copy Markdown
Member

@msyyc msyyc commented Aug 8, 2024

fix #2742 and #2769

  • Fix to get right response and exception
  • Add test cases for cadl-ranch scenario azure-core-model

Comment thread packages/typespec-python/src/utils.ts Outdated
Comment thread packages/typespec-python/src/http.ts
): Record<string, any> {
return {
...emitHttpOperation(context, rootClient, operationGroupName, method.operation),
...emitHttpOperation(context, rootClient, operationGroupName, method.operation, method),
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Python SDK always set response type of initial operation as Binary type so just keep it same as begin_xxx API.

@msyyc msyyc changed the title Add test cases for cadl-ranch scenario azure-core-model Fix to get right response and exception Aug 8, 2024
Comment on lines +333 to +341
if (isException) {
if (response.type && !isAzureCoreErrorResponse(response.type)) {
type = getType(context, response.type);
}
} else if (method && !method.kind.includes("basic")) {
if (method.response.type) {
type = getType(context, method.response.type);
}
} else if (response.type) {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • For exception response, need to filter Azure.Core.ErrorResponse
  • For normal response, there are 2 kinds:
  1. lro/lropaging/paging API: there shall always be one kind of response type so use method.response.type directly
  2. basic API: there may be multi response types, so honor http response type.

t
for t in self.types_map.values()
if isinstance(t, ModelType) and not (self.options["models_mode"] == "dpg" and t.page_result_model)
if isinstance(t, ModelType) and t.usage != UsageFlags.Default.value
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use usage to filter unneeded model.

@msyyc msyyc marked this pull request as ready for review August 9, 2024 03:04
@iscai-msft iscai-msft merged commit 61f3f5a into main Aug 14, 2024
@iscai-msft iscai-msft deleted the add-test branch August 14, 2024 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wrong return type

3 participants