Commit ad99e406 authored by Denis Laxalde's avatar Denis Laxalde
Browse files

Handle Boolean value in JSON Schema renderer

For such values, we do not add the $schema property.
parent a42b6f8d8f63
......@@ -194,10 +194,11 @@ def includeme(config):
)
def jsonschema_dumps(value, **kwargs):
value.setdefault(
'$schema',
'http://json-schema.org/draft-06/schema#',
)
if isinstance(value, dict):
value.setdefault(
'$schema',
'http://json-schema.org/draft-06/schema#',
)
return json.dumps(value, **kwargs)
config.add_renderer(
......
......@@ -57,6 +57,11 @@ class JSONSchemaRendererTC(TestCase):
'type': 'string'},
)
def test_no_metaschema_for_bool(self):
for value in (False, True):
self.assertEqual(renderers.render('jsonschema', value),
str(value).lower())
class BaseTC(PyramidCWTest):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment