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] [Golang] Bug make the http Body readable again #4799

Closed
5 of 6 tasks
Tsovak opened this issue Dec 16, 2019 · 3 comments
Closed
5 of 6 tasks

[BUG] [Golang] Bug make the http Body readable again #4799

Tsovak opened this issue Dec 16, 2019 · 3 comments

Comments

@Tsovak
Copy link

Tsovak commented Dec 16, 2019

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

For Golang need to make HTTPResponse.Body readable again

Now after generating code, the generator read the Http Body one and closed it. After that user cannot read the Body again out the generated client. I suggest making the Body readable again.

openapi-generator version

4.2.3

Suggest a fix

Need to change in the templates localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
to

	localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
	localVarHTTPResponse.Body = _ioutil.NopCloser(bytes.NewBuffer(localVarBody))
@nmische
Copy link
Contributor

nmische commented Dec 20, 2019

I just ran into this issue yesterday and was planning to submit a similar bug report. Is there a PR open to address this issue?

@Tsovak
Copy link
Author

Tsovak commented Dec 24, 2019

@nmische I searched the existed PR but could not find it. I tried to open PR but I didn't have access. So we need to wait for the OpenAPI Team.

@wing328
Copy link
Member

wing328 commented Aug 4, 2020

Thanks for the fix by @nmische

@Tsovak please pull the latest master or snapshot version to give it a try.

@wing328 wing328 closed this as completed Aug 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants