aromanovich / jsl

A Python DSL for describing JSON schemas
http://jsl.readthedocs.org/
Other
218 stars 21 forks source link

return repr formatting rather than human readable text #26

Open wjo1212 opened 8 years ago

wjo1212 commented 8 years ago

run the sample in the guide result: OrderedDict([('$schema', 'http://json-schema.org/draft-04/schema#'), ('definitions', OrderedDict([('__main__.Directory', OrderedDict([('type', 'object'), ('properties', OrderedDict([('name', OrderedDict([('type', 'string')])), ('content', OrderedDict([('type', 'array'), ('items', OrderedDict([('oneOf', [{'$ref': '#/definitions/__main__.File'}, {'$ref': '#/definitions/__main__.Directory'}])]))]))])), ('required', ['name', 'content']), ('additionalProperties', False)])), ('__main__.File', OrderedDict([('type', 'object'), ('properties', OrderedDict([('name', OrderedDict([('type', 'string')])), ('content', OrderedDict([('type', 'string')]))])), ('required', ['name', 'content']), ('additionalProperties', False)]))])), ('$ref', '#/definitions/__main__.Directory')])

SamirBoulil commented 8 years ago

You can fix this issue using:

import json

print(json.dumps(Directory.get_schema(ordered=True), indent=4))

I don't believe we need to change the get_schema implementation, maybe just change the documentation to show how to output the schema the way it is presented.

Cheers ;)