Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bravado tries to parse xml response as JSON #250

Open
bxm156 opened this issue Sep 1, 2016 · 4 comments
Open

Bravado tries to parse xml response as JSON #250

bxm156 opened this issue Sep 1, 2016 · 4 comments

Comments

@bxm156
Copy link
Member

bxm156 commented Sep 1, 2016

One of my endpoints responds with xml data. I specify in the swagger spec that this endpoint produces: application/xml. Despite this, trying to call result() returns a JSONDecodeError.

If I configure 'also_return_response': True, it still tries to parse it as JSON :(

@analogue
Copy link
Contributor

analogue commented Sep 1, 2016

@bxm156
Copy link
Member Author

bxm156 commented Sep 1, 2016

I tried passing in .result(raw_response=True), but it still didn't work. Is raw_response not supported?

@analogue
Copy link
Contributor

analogue commented Sep 1, 2016

swaggerpy (swagger 1.2) was refactored so much whilst adding Swagger 2.0 support (bravado/bravado-core) that it was effectively a rewrite. raw_response didn't make it in the final cut 😢

@bowman
Copy link
Contributor

bowman commented Dec 7, 2016

As a work around I clear the deferred.operation = None, making the current version not try to parse as json. This is really an implementation detail, so relying on it seems like a bad idea.

        :param operation: operation that this http request is for. Defaults
            to None - in which case, we're obviously just retrieving a Swagger
            Spec.

After that you can look at the result text without json parsing:

res = deferred.result()
res.text

Unfortunately, the library doesn't expose the .content() from requests
so I hit a charset encoding slow down https://github.com/kennethreitz/requests/issues/2359

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants