Skip to content

Incorrect code generation for API marked as long-running with response type "file" #3247

@KupoCat

Description

@KupoCat

I am trying to generate a python SDK from openapi swagger files and some of my APIs are marked with "x-ms-long-running-operation". For most of the cases this works fine, and the generated code works, but one of the APIs has a response type of "file":

"responses": {
          "200": {
            "description": "...",
            "schema": {
              "type": "file"
            }
          },
...

In this case, the code is generated incorrectly and calling it results in the following error:

deserialized = response.iter_bytes()
                   ^^^^^^^^
NameError: name 'response' is not defined

Looking at the generated code, it seems there is a slight naming problem in the generated deserialization callback:

def get_long_running_output(pipeline_response):
    deserialized = response.iter_bytes()
    if cls:
        return cls(pipeline_response, deserialized, {})  # type: ignore
    return deserialized

I believe in the above code, response should be pipeline_response, and when I manually change this after the generation the code works and method returns the correct value.

Metadata

Metadata

Assignees

Labels

customer-reportedIssues that are reported by GitHub users external to the Azure organization.questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions