From b12b38d680f69f3d04bbf979e939ecf89ca29db3 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Fri, 14 Oct 2016 11:47:34 +0100 Subject: [PATCH] regrandfather json-formatted example params --- templating/matrix_templates/units.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/templating/matrix_templates/units.py b/templating/matrix_templates/units.py index ed18d972..5205186e 100644 --- a/templating/matrix_templates/units.py +++ b/templating/matrix_templates/units.py @@ -390,7 +390,18 @@ def get_example_for_param(param): schema = param.get('schema') if not schema: return None - return json.dumps(get_example_for_schema(schema), indent=2) + + # allow examples for the top-level object to be in formatted json + exampleobj = None + if 'example' in schema: + exampleobj = schema['example'] + if isinstance(exampleobj, basestring): + return exampleobj + + if exampleobj is None: + exampleobj = get_example_for_schema(schema) + + return json.dumps(exampleobj, indent=2) def get_example_for_response(response): """Returns a stringified example for a response"""