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