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

use flask machinery for json #631

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
use flask machinery for json
ancieg committed Dec 26, 2024
commit a797afcd7683967c831e2ec88e9e658faa03fa09
6 changes: 1 addition & 5 deletions flask_restx/representations.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
try:
from ujson import dumps
except ImportError:
from json import dumps

from flask import make_response, current_app
from flask.json import dumps


def output_json(data, code, headers=None):
10 changes: 3 additions & 7 deletions tests/legacy/test_api_legacy.py
Original file line number Diff line number Diff line change
@@ -334,14 +334,10 @@ def get(self):
assert data == expected

def test_use_custom_jsonencoder(self, app, client):
class CabageEncoder(JSONEncoder):
def default(self, obj):
return "cabbage"
def default(obj):
return "cabbage"

class TestConfig(object):
RESTX_JSON = {"cls": CabageEncoder}

app.config.from_object(TestConfig)
app.json.default = default
api = restx.Api(app)

class Cabbage(restx.Resource):