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

[BUG][csharp-netcore] Failed to deserialize FileParameter when using HttpClient. #10588

Closed
TORISOUP opened this issue Oct 13, 2021 · 3 comments · Fixed by #11850
Closed

[BUG][csharp-netcore] Failed to deserialize FileParameter when using HttpClient. #10588

TORISOUP opened this issue Oct 13, 2021 · 3 comments · Fixed by #11850

Comments

@TORISOUP
Copy link
Contributor

Description

When a client that returns byte[] (FileParameter) as a response is created and called, FileParameter is interpreted as Json and decoded, resulting in an exception.

openapi-generator version

5.2.1.

Related issues/PRs

I'm sorry if this has already been pointed out.

Suggest a fix/enhancement

In the next conditional branch, it looks like the fact that FileParameter is passed is not taken into account.

https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/ApiClient.mustache#L99-L147

For now, by adding the following code, I was able to get the byte[] without any error.

if (type == typeof(FileParameter))
{
    return new FileParameter(await response.Content.ReadAsStreamAsync());
}
@TORISOUP TORISOUP closed this as completed Nov 4, 2021
@NoTuxNoBux
Copy link
Contributor

Hi

Any reason this has been closed? We ran into the same issue today. FileParameter is used correctly as class for responses that contain binary files, but when the API call is performed, the code still tries to deserialize it as JSON.

@TORISOUP
Copy link
Contributor Author

The reason I closed the issue was not because it was resolved, but because I thought I made a mistake in the issue submission flow.

I have added the above process to deal with it, but it does not solve the root problem.
It may be a good idea to submit the issue again.

@TORISOUP TORISOUP reopened this Jan 18, 2022
@TORISOUP
Copy link
Contributor Author

I've reopened it for now.
However, I'm not sure if I've registered the issue in the correct flow. (Is the issue being managed outside of GitHub?)

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 a pull request may close this issue.

2 participants