Skip to content

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

@Tsovak

Description

@Tsovak

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))

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions