def jsonschema_options(collection): collection = JSONSCHEMAS_VERSIONS.get(collection, collection) jsonschema_options_path = os.path.join(os.path.dirname(__file__), 'jsonschemas', 'options', '{0}.js'.format(collection)) return Response(stream_file(jsonschema_options_path), mimetype='application/javascript')
def jsonschema(collection): collection = JSONSCHEMAS_VERSIONS.get(collection, collection) jsonschema_path = os.path.join(os.path.dirname(__file__), 'jsonschemas', 'records', '{0}.json'.format(collection)) json_resolver = JSONResolver( plugins=['cap.modules.records.resolvers.jsonschemas']) with open(jsonschema_path) as file: jsonschema_content = file.read() try: result = JsonRef.replace_refs(json.loads( jsonschema_content), loader=json_resolver.resolve) ren = render_template( 'records/deposit-base-extended.html', schema=json.dumps(result, indent=4)) return jsonify(json.loads(ren)) except: return jsonify(json.loads(render_template('records/deposit-base-refs.html', collection=collection)))
def jsonschema_deposit(collection): collection = JSONSCHEMAS_VERSIONS.get(collection, collection) jsonschema_path = os.path.join(os.path.dirname(__file__), 'jsonschemas', 'records', '{0}.json'.format(collection)) json_resolver = JSONResolver( plugins=['cap.modules.records.resolvers.jsonschemas']) with open(jsonschema_path) as file: jsonschema_content = file.read() try: result = JsonRef.replace_refs(json.loads( jsonschema_content), loader=json_resolver.resolve) return jsonify(result) except: jsonschema_path = os.path.join(os.path.dirname(__file__), 'jsonschemas_gen', 'records', '{0}.json'.format(collection)) with open(jsonschema_path) as file: jsonschema_content = json.loads(file.read()) return jsonify(jsonschema_content)