Skip to content

Commit

Permalink
Merge pull request #102 from jvinet/master
Browse files Browse the repository at this point in the history
Add support for extension members in Problem Detail packets
  • Loading branch information
jmcs committed Dec 4, 2015
2 parents 5b025cb + 696e228 commit b2c189d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion connexion/problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import json


def problem(status, title, detail, type='about:blank', instance=None, headers=None):
def problem(status, title, detail, type='about:blank', instance=None, headers=None, ext=None):
"""
Returns a `Problem Details <https://tools.ietf.org/html/draft-ietf-appsawg-http-problem-00>`_ error response.
Expand All @@ -36,12 +36,16 @@ def problem(status, title, detail, type='about:blank', instance=None, headers=No
:type type: str | None
:param headers: HTTP headers to include in the response
:type headers: dict | None
:param ext: Extension members to include in the body
:type ext: dict | None
:return: Json serialized error response
:rtype: flask.Response
"""
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)
response = flask.current_app.response_class(body, mimetype='application/problem+json',
Expand Down

0 comments on commit b2c189d

Please sign in to comment.