swagger-api / swagger-api/swagger-codegen-generators
[python] python client returns a bad binary representation of string for text/plain responses
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 299
- Forks
- 439
- PR merge metrics
- No merged PRs in 30d
Description
With this response type
responses:
200:
description: success
content:
text/plain:
schema:
type: string
example: ok
The you get the following response from the generated client:
"b'ok'"
This is due to the fact the retuned body is in bytes and then the deserialisation tries to make a string of it and in newer python this generates a repr of the bytes which corresponds to this string.
The proper way would be to decode the binary body according to charset returned or ascii for all content type "text/" before any fancy handling of the swagger specific types.
Then maybe also the str conversion in serialisation can be removed for string type.
I will send a pull request solving this in a moment.
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 the generated Python client's response deserialization and serialization paths for text/plain responses. Reproduce the example with a string response, then verify that the client returns the decoded string rather than a bytes representation and that existing generated-client tests still pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100