openapi-python-sdk icon indicating copy to clipboard operation
openapi-python-sdk copied to clipboard

JSON response returned as string instead of dict (Flask integration)

Open francescobianco opened this issue 8 months ago • 3 comments

JSON response returned as string instead of dict (Flask integration)

Description
SDK returns raw string instead of parsed JSON, adding boilerplate in Flask apps.

Code snippet

from flask import Flask
import json

app = Flask(__name__)

resp = client.request("GET", base_url, "/advance")
data = json.loads(resp)

Issue
Expected automatic JSON decoding.

francescobianco avatar Mar 18 '26 14:03 francescobianco

Hey @francescobianco

Check this PR #12

Deadpool2000 avatar Mar 18 '26 16:03 Deadpool2000

I think the issue might be due to the fact that the client.request method is returning a raw string instead of a JSON object. Could you try checking the client.request method in openapi_python_sdk.client to see if it's explicitly returning a string or if there's an option to enable automatic JSON decoding?

IlyasFardaouix avatar Mar 19 '26 04:03 IlyasFardaouix

Good point, thanks @IlyasFardaouix for digging into this.

We’re currently working on improving the test suite around this area, so things are still being refined. For now, we’re happy to accept any useful contributions that help move this forward.

Feel free to share ideas or open follow-up PRs if you find something that works well.

francescobianco avatar Mar 24 '26 10:03 francescobianco