Skip to content

[python] python client returns a bad binary representation of string for text/plain responses #1347

@trollkarlen

Description

@trollkarlen

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions