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

working swagger

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