Commit 10acdfee authored by Zahra Najafabadi's avatar Zahra Najafabadi

working swagger

parent 6adaca17
......@@ -42,7 +42,7 @@ paths:
description: "The raw dataset to be added"
required: true
schema:
$ref: "#/definitions/Dataset-UpperCase"
$ref: "#/definitions/Dataset"
responses:
201:
description: "Successful operation"
......@@ -67,7 +67,7 @@ paths:
- "raw_dataset"
summary: "Get single usecase dataset"
parameters:
- name: "usecase"
- name: "name"
in: "path"
description: "Name of the requested usecase dataset"
required: true
......
......@@ -22,7 +22,7 @@ class Repository(MongoRepositoryBase):
#region Raw_data
def add_raw_data(self, dataset: json):
def add_raw_data(self, dataset: Raw_Dataset):
super().insert_entry(self._raw_dataset, dataset.to_serializable_dict())
def get_all_raw_data(self) -> List[Raw_Dataset]:
......@@ -31,7 +31,7 @@ class Repository(MongoRepositoryBase):
def get_raw_data(self, usecase_name) -> Raw_Dataset:
entries = super().get_entries(self._raw_dataset, selection={'usecase_name': usecase_name})
entries = [Raw_Dataset(e) for e in entries]
return [Raw_Dataset(e) for e in entries]
# end region
......
......@@ -25,7 +25,7 @@ def message_received_callback(channel, method, properties, body):
app = connexion.App(__name__, specification_dir='configs/')
app.add_api('swagger.yml')
@app.rest('/', methods=['GET'])
@app.route('/', methods=['GET'])
def api_root():
return 'Endpoint of semantic-linking-microservice!'
......
......@@ -2,6 +2,7 @@ from flask import request, Response
from db.repository import Repository
import json
from db.entities import Raw_Dataset
repo = Repository()
......@@ -15,10 +16,7 @@ def post():
def _insert_raw_data(raw_dataset:json):
'''Converts object keys from external source and inserts into database.'''
raw_dataset['usecase_name'] = raw_dataset.pop('usecase_name')
raw_dataset['properties'] = raw_dataset.pop('properties')
repo.add_raw_data(raw_dataset)
repo.add_raw_data(Raw_Dataset(raw_dataset))
def get():
return [dataset.to_serializable_dict() for dataset in repo.get_all_raw_data()]
......@@ -26,7 +24,7 @@ def get():
def get_by_usecase(name):
res = repo.get_raw_data(name)
if res is not None:
return res.to_serializable_dict()
return [element.to_serializable_dict() for element in res]
else:
return Response(status=404)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment