Skip to content

Instantly share code, notes, and snippets.

@hugoledoux
Last active June 19, 2019 12:50
Show Gist options
  • Save hugoledoux/4002869e257c56341722f0302a37c73e to your computer and use it in GitHub Desktop.
Save hugoledoux/4002869e257c56341722f0302a37c73e to your computer and use it in GitHub Desktop.
stitch diff JSON schemas into one (in this case CityJSON)
import os
import sys
import json
import jsonschema
import jsonref
root_schema = os.path.abspath('../schemas/cityjson.schema.json')
print (root_schema)
fins = open(root_schema)
sys.exit()
abs_path = os.path.abspath(os.path.dirname(root_schema))
base_uri = 'file://{}/'.format(abs_path)
js = jsonref.loads(fins.read(), jsonschema=True, base_uri=base_uri)
# -- output stitched_schema
json_str = json.dumps(js)
f = open('../schemas/cityjson.min.schema.json', "w")
f.write(json_str)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment