Remove grandfathering for json strings

Examples now have to be raw objects rather than json strings
pull/977/head
Richard van der Hoff 7 years ago
parent 820704a16a
commit 70ec3237b6

@ -340,12 +340,9 @@ def get_example_for_param(param):
if not schema: if not schema:
return None return None
# allow examples for the top-level object to be in formatted json
exampleobj = None exampleobj = None
if 'example' in schema: if 'example' in schema:
exampleobj = schema['example'] exampleobj = schema['example']
if isinstance(exampleobj, basestring):
return exampleobj
if exampleobj is None: if exampleobj is None:
exampleobj = get_example_for_schema(schema) exampleobj = get_example_for_schema(schema)
@ -357,15 +354,6 @@ def get_example_for_response(response):
exampleobj = None exampleobj = None
if 'examples' in response: if 'examples' in response:
exampleobj = response["examples"].get("application/json") exampleobj = response["examples"].get("application/json")
# the openapi spec suggests that examples in the 'examples' section should
# be formatted as raw objects rather than json-formatted strings, but we
# have lots of the latter in our spec, which work with the swagger UI,
# so grandfather them in.
#
# FIXME: swagger-ui no longer supports this. We should fix the inputs
# and remove the grandfathering.
if isinstance(exampleobj, basestring):
return exampleobj
if exampleobj is None: if exampleobj is None:
schema = response.get('schema') schema = response.get('schema')

Loading…
Cancel
Save