Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def build_spec(user, repo, sha=None, prov=None, extraMetadata=[]):
"""Build grlc specification for the given github user / repo."""
loader = grlc.utils.getLoader(user, repo, sha=sha, prov=prov)
files = loader.fetchFiles()
raw_repo_uri = loader.getRawRepoUri()
# Fetch all .rq files
items = []
allowed_ext = ["rq", "sparql", "json", "tpf"]
for c in files:
glogger.debug('>>>>>>>>>>>>>>>>>>>>>>>>>c_name: {}'.format(c['name']))
extension = c['name'].split('.')[-1]
if extension in allowed_ext:
call_name = c['name'].split('.')[0]
# Retrieve extra metadata from the query decorators
query_text = loader.getTextFor(c)
def swagger_spec(user, repo, sha=None, content=None):
glogger.info("-----> Generating swagger spec for /{}/{} on commit {}".format(user, repo, sha))
swag = utils.build_swagger_spec(user, repo, sha, static.SERVER_NAME)
if 'text/turtle' in request.headers['Accept']:
resp_spec = make_response(utils.turtleize(swag))
resp_spec.headers['Content-Type'] = 'text/turtle'
else:
resp_spec = make_response(jsonify(swag))
resp_spec.headers['Content-Type'] = 'application/json'
resp_spec.headers['Cache-Control'] = static.CACHE_CONTROL_POLICY # Caching JSON specs for 15 minutes
glogger.info("-----> API spec generation for /{}/{} on commit {} complete".format(user, repo, sha))
return resp_spec
def swagger_spec(user, repo, sha=None, content=None):
glogger.info("-----> Generating swagger spec for /{}/{} on commit {}".format(user, repo, sha))
swag = utils.build_swagger_spec(user, repo, sha, static.SERVER_NAME)
if 'text/turtle' in request.headers['Accept']:
resp_spec = make_response(utils.turtleize(swag))
resp_spec.headers['Content-Type'] = 'text/turtle'
else:
resp_spec = make_response(jsonify(swag))
resp_spec.headers['Content-Type'] = 'application/json'
resp_spec.headers['Cache-Control'] = static.CACHE_CONTROL_POLICY # Caching JSON specs for 15 minutes
glogger.info("-----> API spec generation for /{}/{} on commit {} complete".format(user, repo, sha))
return resp_spec