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

No json pretty printing #313

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion connexion/decorators/produces.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def wrapper(*args, **kwargs):
logger.debug('Endpoint returned an empty response (204)', extra={'url': url, 'mimetype': self.mimetype})
return '', 204, headers

data = [json.dumps(data, indent=2), '\n']
data = json.dumps(data)
response = flask.current_app.response_class(data, mimetype=self.mimetype) # type: flask.Response
response = self.process_headers(response, headers)

Expand Down
4 changes: 2 additions & 2 deletions connexion/problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ def problem(status, title, detail, type='about:blank', instance=None, headers=No
:return: Json serialized error response
:rtype: flask.Response
"""
problem_response = {'type': type, 'title': title, 'detail': detail, 'status': status, }
problem_response = {'type': type, 'title': title, 'detail': detail, 'status': status}
if instance:
problem_response['instance'] = instance
if ext:
problem_response.update(ext)

body = [json.dumps(problem_response, indent=2), '\n']
body = json.dumps(problem_response)
response = flask.current_app.response_class(body, mimetype='application/problem+json',
status=status) # type: flask.Response
if headers:
Expand Down
4 changes: 2 additions & 2 deletions tests/api/test_bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,13 @@ def route2():
def test_resolve_method(simple_app):
app_client = simple_app.app.test_client()
resp = app_client.get('/v1.0/resolver-test/method') # type: flask.Response
assert resp.data.decode() == '"DummyClass"\n'
assert resp.data.decode() == '"DummyClass"'


def test_resolve_classmethod(simple_app):
app_client = simple_app.app.test_client()
resp = app_client.get('/v1.0/resolver-test/classmethod') # type: flask.Response
assert resp.data.decode() == '"DummyClass"\n'
assert resp.data.decode() == '"DummyClass"'


def test_add_api_with_function_resolver_function_is_wrapped(simple_api_spec_dir):
Expand Down
4 changes: 2 additions & 2 deletions tests/api/test_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def test_strict_extra_query_param(strict_app):
def test_path_parameter_someint(simple_app):
app_client = simple_app.app.test_client()
resp = app_client.get('/v1.0/test-int-path/123') # type: flask.Response
assert resp.data.decode() == '"int"\n'
assert resp.data.decode() == '"int"'

# non-integer values will not match Flask route
resp = app_client.get('/v1.0/test-int-path/foo') # type: flask.Response
Expand All @@ -84,7 +84,7 @@ def test_path_parameter_someint(simple_app):
def test_path_parameter_somefloat(simple_app):
app_client = simple_app.app.test_client()
resp = app_client.get('/v1.0/test-float-path/123.45') # type: flask.Response
assert resp.data.decode() == '"float"\n'
assert resp.data.decode() == '"float"'

# non-float values will not match Flask route
resp = app_client.get('/v1.0/test-float-path/123,45') # type: flask.Response
Expand Down