Skip to content

[BUG] Python: Bad return for json like str response  #17987

@dyens

Description

@dyens

Hi!

I faced up with a problem in kubernetes python client kubernetes-client/python#2196.
This client use openapi-generator. For str responses that looks like a good json we have a bad transformation:

{"a": "a"} \\ valid json string
comes to
{'a': 'a'} \\ not valid

The reason for this in this line:

There we have

response_type == 'str' 
response.data == '{"a": "a"}'

This is a valid json, so after L340:

data == {'a': 'a'}  # this is a dict object in python (no more string)

Then self.__deserialize_primitive transforms this dict to string:

return klass(data) # where klass == str, data =  {'a': 'a'} 

In python str(dict(a="a")) == {'a': 'a'}

So, after this transformations double quotes replaced by ordinary quotes.

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