swagger-api / swagger-api/swagger-codegen
[PHP] getContents returns empty string after middleware
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Hi!
I use swagger-codegen version 2.4.25 for PHP client.
When I use client with logger middleware getContents returns empty string.
And I know why. Because method getContents returns the remaining contents in a string.
If you use logger pointer set to end of body. And getContents returns empty string.
instead of $content = $responseBody->getContents(); you need to $content = $responseBody->__toString();
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with modules/swagger-codegen/src/main/resources/php/api.mustache at the response-body handling around line 163. Reproduce the generated PHP client's behavior with logger middleware, then verify that response content is still returned after the middleware has read the body. Done means the generated client no longer returns an empty string in that case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- api
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100