Skip to content
Snippets Groups Projects
Commit 686fc844 authored by Cornelia Michlits's avatar Cornelia Michlits
Browse files

add descriptions, update flasgger endpoints

parent 4d5a0695
No related branches found
No related tags found
3 merge requests!129New module for citation as they occur multiple,!121Modified logging, modified logging level, modified flasgger endpoint,!102240 onto incl
......@@ -87,7 +87,7 @@ def validate(unit):
except Exception as e:
logging.error(e)
res = {"success": False, "message": str(e)}
return jsonify(res)
return jsonify(res), 500
@app.route('/api/units/uri/<uname>', methods=["GET"], endpoint='uri')
......@@ -141,7 +141,7 @@ def save_column_concept():
res = {"success": False, "message": str(e)}
return jsonify(res), 500
@app.route('/api/units/getconcept/<cname>', methods=["GET"], endpoint='get_concept')
@app.route('/api/ontologies/getconcept/<cname>', methods=["GET"], endpoint='get_concept')
@swag_from('getconcept.yml')
def get_concept(cname):
logging.debug('endpoint get concept, cname=%s, body=%s', cname, request)
......@@ -156,33 +156,33 @@ def get_concept(cname):
ONTOLOGIES_DIRECTORY = 'ontologies'
@app.route('/api/ontologies', methods=["POST"], endpoint='upload_onto')
@swag_from('ontologie.yml')
@app.route('/api/ontology', methods=["POST"], endpoint='upload_onto')
@swag_from('ontologies.yml')
def post_ontologies():
if 'file' not in request.files:
return "no file", 500
file = request.files['file']
if file.filename == '':
return "no file selected", 500
return "no file selected", 400
if file and allowed_file(file.filename):
filename = secure_filename(file.filename)
if ontology_exists(Path(filename).stem):
return "ontology name already exists", 500
return "ontology name already exists", 409
setup_ontology_dir()
file.save(os.path.join(ONTOLOGIES_DIRECTORY, filename))
logging.debug('created ontology: %s', filename)
return "created", 200
return "created", 201
@app.route('/api/ontologies', methods=["GET"], endpoint='get_ontos')
@swag_from('ontologies.yml')
@swag_from('ontology.yml')
def get_ontologies():
print(list_ontologies())
return jsonify(list_ontologies())
@app.route('/api/ontologies/<name>', methods=["GET"], endpoint='get_onto')
@swag_from('ontologie.yml')
def get_ontologies(name):
ontology = get_ontology(name)
@app.route('/api/ontologies/<o_name>', methods=["GET"], endpoint='get_onto')
@swag_from('ontologybyname.yml')
def get_ontologies(o_name):
ontology = get_ontology(o_name)
if ontology is None:
return "ontology does not exist", 404
return ontology
......
......@@ -3,6 +3,7 @@ import glob
import sys
import os
from pathlib import Path
import rdflib
ALLOWED_EXTENSIONS = {'ttl', 'nt'}
......
......@@ -8,7 +8,7 @@ parameters:
- in: "path"
type: "string"
name: "cname"
description: "Enter a table name or attribute name.´"
description: "Enter a concept name."
required: true
responses:
200:
......
summary: "Get list of ontologies"
description: "This is a simple API for getting the list of all ontologies contained in DB-Repo."
summary: "Post / Upload ontology"
description: "This is a simple API for posting ontologies (.nt, .ttl files) to DB-Repo."
consumes:
- "application/json"
produces:
- "application/json"
parameters:
- name: file
required: false
in: formData
type: file
responses:
200:
description: "OK"
201:
description: "Created"
400:
description: "Bad request"
405:
description: "Invalid input"
409:
description: "Conflict"
\ No newline at end of file
summary: "Get ontology"
description: "This is a simple API for getting ontologies (.nt, .ttl files) used in DB-Repo."
description: "This is a simple API for listing all ontologies (.nt, .ttl files) used in DB-Repo."
consumes:
- "application/json"
produces:
- "application/json"
parameters:
- name: file
required: false
in: formData
type: file
responses:
200:
description: "OK"
201:
description: "Created"
405:
description: "Invalid input"
\ No newline at end of file
summary: "Get ontology"
description: "This is a simple API for getting a certain ontologies (.nt, .ttl files) stored in DB-Repo."
consumes:
- "application/json"
produces:
- "application/json"
parameters:
- name: o_name
in: path
required: true
type: string
default: "VOCAB_QUDT-UNITS-ALL-v2.1"
responses:
200:
description: "OK"
404:
description: "Not found"
405:
description: "Invalid input"
......@@ -7,7 +7,7 @@ produces:
parameters:
- in: "body"
name: "body"
description: "to-do description"
description: "Json containing ustring, i.e., string of a unit, and an offset."
required: true
schema:
type: "object"
......
......@@ -8,7 +8,7 @@ parameters:
- in: "path"
type: "string"
name: "unit"
description: "to-do description"
description: "Validates unit against om-2."
required: true
responses:
200:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment