Format examples as raw objects

According the the openapi spec, examples for responses and schemas should be
raw objects rather than being json strings. (It's unclear what non-json
examples should look like...).

The swagger UI used to support json strings, but no longer does. In short,
let's turn the json strings into their raw formats.
This commit is contained in:
Richard van der Hoff 2017-09-26 17:53:28 +01:00
parent 0795f3667e
commit 820704a16a
44 changed files with 183 additions and 290 deletions

View file

@ -45,15 +45,8 @@ except ImportError as e:
def check_parameter(filepath, request, parameter):
schema = parameter.get("schema")
example = None
try:
example_json = schema.get('example')
if example_json and not schema.get("format") == "byte":
example = json.loads(example_json)
except Exception as e:
raise ValueError("Error parsing JSON example request for %r" % (
request
), e)
example = schema.get('example')
fileurl = "file://" + os.path.abspath(filepath)
if example and schema:
try:
@ -72,15 +65,7 @@ def check_parameter(filepath, request, parameter):
def check_response(filepath, request, code, response):
example = None
try:
example_json = response.get('examples', {}).get('application/json')
if example_json:
example = json.loads(example_json)
except Exception as e:
raise ValueError("Error parsing JSON example response for %r %r" % (
request, code
), e)
example = response.get('examples', {}).get('application/json')
schema = response.get('schema')
fileurl = "file://" + os.path.abspath(filepath)
if example and schema: