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

[v6] improve contentType detection in overloaded methods #619

Merged
merged 1 commit into from
Apr 16, 2020

Conversation

chradek
Copy link
Contributor

@chradek chradek commented Apr 16, 2020

@jeremymeng found an issue where when an operation has overloads, contentType is misidentified in the arguments list.

The reason for this is because previously, we were detecting which argument is the contentType by looking at the code model's operation.requests array and getting the index from that. However, if all the overloads share parameters, those parameters are on operation.parameters. This meant that if a parameter from operation.parameters showed up in the overload before the ones in operation.requests[i].parameters, the contentType lookup would be incorrect.

In some cases (though I haven't been able to identify when) this actually does occur. For example, in form-recognizer. Interestingly when I tried copying the operation that had an issue in form-recognizer into a new swagger model and generated a client for it, contentType was always the first parameter. I was able to verify this change fixes the issue by regenerating form-recognizer.

You can see the issue in the generated code here:
Capture

After this change, args[1] is correctly checked in the if/else statements for contentType.

Copy link
Member

@joheredi joheredi left a comment

Choose a reason for hiding this comment

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

Looks good!

@chradek chradek merged commit 8faad8c into Azure:v6 Apr 16, 2020
@chradek chradek deleted the content-type-body-fix branch April 16, 2020 20:45
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.

2 participants