Skip to content
Snippets Groups Projects
Unverified Commit d0cc05bf authored by Martin Weise's avatar Martin Weise
Browse files

Hotfix the metrics and swagger-ui

parent 2f2219e5
No related branches found
No related tags found
3 merge requests!231CI: Remove build for log-service,!228Better error message handling in the frontend,!223Release of version 1.4.0
......@@ -279,10 +279,8 @@ CREATE TABLE IF NOT EXISTS `mdb_concepts`
name VARCHAR(255) null,
description TEXT null,
created timestamp NOT NULL DEFAULT NOW(),
created_by character varying(36) NOT NULL,
PRIMARY KEY (id),
UNIQUE (uri(200)),
FOREIGN KEY (created_by) REFERENCES mdb_users (id)
UNIQUE (uri(200))
) WITH SYSTEM VERSIONING;
CREATE TABLE IF NOT EXISTS `mdb_units`
......@@ -292,10 +290,8 @@ CREATE TABLE IF NOT EXISTS `mdb_units`
name VARCHAR(255) null,
description TEXT null,
created timestamp NOT NULL DEFAULT NOW(),
created_by character varying(36) NOT NULL,
PRIMARY KEY (id),
UNIQUE (uri(200)),
FOREIGN KEY (created_by) REFERENCES mdb_users (id)
UNIQUE (uri(200))
) WITH SYSTEM VERSIONING;
CREATE TABLE IF NOT EXISTS `mdb_columns_concepts`
......
FROM python:3.10-alpine
RUN adduser -D alpine
RUN apk add bash curl && adduser -D alpine
WORKDIR /home/alpine
......@@ -12,6 +12,7 @@ RUN pip install pipenv && \
COPY ./app ./app
COPY ./scripts ./scripts
COPY ./us-yml ./us-yml
COPY config.py wsgi.py ./
ENV FLASK_APP=wsgi.py
......
......@@ -2,7 +2,7 @@
import os
import logging
from flasgger import LazyJSONEncoder
from flasgger import LazyJSONEncoder, Swagger
from flask import Flask
from opensearchpy import OpenSearch
from config import Config
......@@ -41,7 +41,55 @@ def create_app(config_class=Config):
metrics = PrometheusMetrics(app)
metrics.info("app_info", "Application info", version="0.0.1")
app.config["SWAGGER"] = {"openapi": "3.0.0", "title": "Swagger UI", "uiversion": 3}
app.config["SWAGGER"] = {"openapi": "3.0.1", "title": "Swagger UI", "uiversion": 3}
swagger_config = {
"headers": [],
"specs": [
{
"endpoint": "api-search",
"route": "/api-search.json",
"rule_filter": lambda rule: rule.endpoint.startswith('actuator'),
"model_filter": lambda tag: True, # all in
}
],
"static_url_path": "/flasgger_static",
"swagger_ui": True,
"specs_route": "/swagger-ui/",
}
template = {
"openapi": "3.0.0",
"info": {
"title": "Database Repository Search Service API",
"description": "Service that searches the search database",
"version": "1.3.0",
"contact": {
"name": "Prof. Andreas Rauber",
"email": "andreas.rauber@tuwien.ac.at"
},
"license": {
"name": "Apache 2.0",
"url": "https://www.apache.org/licenses/LICENSE-2.0"
},
},
"externalDocs": {
"description": "Sourcecode Documentation",
"url": "https://gitlab.phaidra.org/fair-data-austria-db-repository/fda-services"
},
"servers": [
{
"url": "http://localhost:4000",
"description": "Generated server url"
},
{
"url": "https://test.dbrepo.tuwien.ac.at",
"description": "Sandbox"
}
]
}
swagger = Swagger(app, config=swagger_config, template=template)
# https://flask-jwt-extended.readthedocs.io/en/stable/options/
app.config["JWT_ALGORITHM"] = "HS256"
app.config["JWT_DECODE_ISSUER"] = os.getenv("JWT_ISSUER")
......
from flask import Blueprint
api_bp = Blueprint("api", __name__, url_prefix="/api/search")
api_bp = Blueprint("api", __name__)
from app.api import routes
......@@ -56,7 +56,13 @@ def general_filter(index, results):
return results
@api_bp.route("<string:index>", methods=["GET"], endpoint="endpoint")
@api_bp.route("/health", methods=["GET"], endpoint="actuator_health")
@swag_from("us-yml/get_health") # ToDo: get the SWAG right
def health():
return {"status": "UP"}
@api_bp.route("/api/search/<string:index>", methods=["GET"], endpoint="search_get_index")
@swag_from("us-yml") # ToDo: get the SWAG right
def get_index(index):
"""
......@@ -91,7 +97,7 @@ def get_index(index):
return {"results": results, "total": total_number_of_results, "status": 200}
@api_bp.route("<string:index>/fields", methods=["GET"], endpoint="blabla")
@api_bp.route("/api/search/<string:index>/fields", methods=["GET"], endpoint="search_get_index_fields")
def get_fields(index):
"""
returns a list of attributes of the data for a specific index.
......@@ -120,7 +126,7 @@ def get_fields(index):
return {"fields": fields, "status": 200}
@api_bp.route("", methods=["POST"], endpoint="endpoint2")
@api_bp.route("/api/search", methods=["POST"], endpoint="search_fuzzy_search")
def search():
"""
Main endpoint for general searching.
......
summary: Return a healthcheck
description: |
Return UP if the instance is ready to serve connections.
consumes:
- application/json
produces:
- application/json
parameters: []
definitions:
Health:
type: object
properties:
status:
type: string
description: UP
responses:
200:
description: OK, service is up and running
schema:
$ref: "#/definitions/Column"
404:
description: Service is not yet ready
tags:
- actuator
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment