Commit 39e4f5d5 authored by Konstantin Schulz's avatar Konstantin Schulz
Browse files

openAPI documentation is now accessible at /mc/api/v1.0/ui

parent 70e003f0
Pipeline #11606 passed with stages
in 2 minutes and 59 seconds
......@@ -61,17 +61,16 @@ def create_app(cfg: Type[Config] = Config) -> Flask:
return app
def full_init(app: Flask, is_csm: bool) -> None:
def full_init(app: Flask, cfg: Type[Config] = Config) -> None:
""" Fully initializes the application, including logging."""
if is_csm:
from mcserver.app.services import DatabaseService
DatabaseService.init_db_update_info()
DatabaseService.update_exercises(is_csm=is_csm)
DatabaseService.init_db_corpus()
if not app.config["TESTING"]:
from mcserver.app.services.corpusService import CorpusService
CorpusService.init_graphannis_logging()
start_updater(app)
from mcserver.app.services import DatabaseService
DatabaseService.init_db_update_info()
DatabaseService.update_exercises(is_csm=True)
DatabaseService.init_db_corpus()
if not cfg.TESTING:
from mcserver.app.services.corpusService import CorpusService
CorpusService.init_graphannis_logging()
start_updater(app)
def init_app_common(cfg: Type[Config] = Config, is_csm: bool = False) -> Flask:
......@@ -91,14 +90,13 @@ def init_app_common(cfg: Type[Config] = Config, is_csm: bool = False) -> Flask:
if is_csm:
from mcserver.app.services.databaseService import DatabaseService
DatabaseService.init_db_alembic()
tables: List[str] = [Config.DATABASE_TABLE_ALEMBIC, Config.DATABASE_TABLE_CORPUS, Config.DATABASE_TABLE_EXERCISE,
Config.DATABASE_TABLE_UPDATEINFO]
if any(not db.engine.dialect.has_table(db.engine, x) for x in tables):
if is_csm or cfg.TESTING:
db.create_all()
from mcserver.app.services.textService import TextService
TextService.init_proper_nouns_list()
TextService.init_stop_words_latin()
full_init(app, is_csm)
if is_csm:
full_init(app, cfg)
return app
......
"""The corpus list API. Add it to your REST API to provide users with a list of metadata for available texts."""
from datetime import datetime
from connexion.lifecycle import ConnexionResponse
from flask import Response
from sqlalchemy.exc import OperationalError, InvalidRequestError
......
......@@ -758,7 +758,7 @@ class CsmTestCase(unittest.TestCase):
Mocks.app_dict[self.class_name].app.config["TESTING"] = False
with patch.object(CorpusService, "init_graphannis_logging"):
with patch.object(mcserver.app, "start_updater") as updater_mock:
full_init(Mocks.app_dict[self.class_name].app, True)
full_init(Mocks.app_dict[self.class_name].app)
self.assertEqual(updater_mock.call_count, 1)
Mocks.app_dict[self.class_name].app.config["TESTING"] = True
db.session.query(UpdateInfo).delete()
......
......@@ -32,10 +32,17 @@ http {
index index.html index.htm;
# enable CORS so the cordova files (config.xml) can be accessed from other domains
add_header Access-Control-Allow-Origin *;
rewrite ^(.*)mc-service(.*)^ http://localhost:5000$2 last;
try_files $uri $uri/ /index.html =404;
}
# dirty hack to redirect the OpenAPI requests for their schema definition
location ~ /openapi.json$ {
resolver 127.0.0.11 valid=30s;
set $backend_host mcserver;
rewrite /(.*) /mc/$1 break;
proxy_pass http://$backend_host:5000;
}
location /mc-service/ {
resolver 127.0.0.11 valid=30s;
set $backend_host mcserver;
......
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