From f3d11d082fa5b26c162bb96da078dfbf2786a425 Mon Sep 17 00:00:00 2001 From: Amund Isaksen Date: Wed, 4 Dec 2024 08:40:21 +0100 Subject: [PATCH] Update openapi and landing page info --- api/main.py | 3 +- api/metadata_endpoints.py | 50 +++++++++++++++++++++++++++------ api/openapi/openapi_metadata.py | 15 ++++++++++ 3 files changed, 59 insertions(+), 9 deletions(-) create mode 100644 api/openapi/openapi_metadata.py diff --git a/api/main.py b/api/main.py index 25490db4..1809b1bc 100644 --- a/api/main.py +++ b/api/main.py @@ -15,6 +15,7 @@ from utilities import create_url_from_request from export_metrics import add_metrics +from openapi.openapi_metadata import openapi_metadata def setup_logging(): @@ -30,7 +31,7 @@ def setup_logging(): logger = logging.getLogger(__name__) -app = FastAPI(swagger_ui_parameters={"tryItOutEnabled": True}) +app = FastAPI(swagger_ui_parameters={"tryItOutEnabled": True}, **openapi_metadata) app.add_middleware(BrotliMiddleware) add_metrics(app) diff --git a/api/metadata_endpoints.py b/api/metadata_endpoints.py index 34eb3312..590b067f 100644 --- a/api/metadata_endpoints.py +++ b/api/metadata_endpoints.py @@ -26,7 +26,11 @@ from grpc_getter import get_ts_ag_request import datastore_pb2 as dstore -from utilities import get_unique_values_for_metadata, seconds_to_iso_8601_duration, convert_cm_to_m +from utilities import ( + get_unique_values_for_metadata, + seconds_to_iso_8601_duration, + convert_cm_to_m, +) logger = logging.getLogger(__name__) logger.setLevel(logging.INFO) @@ -56,14 +60,33 @@ def datetime_to_iso_string(value: datetime) -> str: def get_landing_page(request): return LandingPageModel( - title="E-SOH EDR API", - description="The E-SOH EDR API", - keywords=["weather", "temperature", "wind", "humidity", "pressure", "clouds", "radiation"], + title="EDR Observations API Europe EUMETNET", + description="OGC EDR API data service for European environmental observations from EUMETNET," + " co-funded by the European Union.", + keywords=[ + "weather", + "temperature", + "wind", + "humidity", + "pressure", + "clouds", + "radiation", + ], provider=Provider(name="RODEO", url="https://rodeo-project.eu/"), contact=Contact(email="rodeoproject@fmi.fi"), links=[ - Link(href=f"{request.url}", rel="self", title="Landing Page in JSON", type="application/json"), - Link(href=f"{request.url}docs", rel="service-doc", title="API description in HTML", type="text/html"), + Link( + href=f"{request.url}", + rel="self", + title="Landing Page in JSON", + type="application/json", + ), + Link( + href=f"{request.url}docs", + rel="service-doc", + title="API description in HTML", + type="text/html", + ), Link( href=f"{request.url}openapi.json", rel="service-desc", @@ -76,7 +99,11 @@ def get_landing_page(request): title="Conformance Declaration in JSON", type="application/json", ), - Link(href=f"{request.url}collections", rel="data", title="Collections metadata in JSON"), + Link( + href=f"{request.url}collections", + rel="data", + title="Collections metadata in JSON", + ), ], ) @@ -155,7 +182,14 @@ async def get_collection_metadata(base_url: str, is_self) -> Collection: ], extent=Extent( spatial=Spatial( - bbox=[[spatial_extent.left, spatial_extent.bottom, spatial_extent.right, spatial_extent.top]], + bbox=[ + [ + spatial_extent.left, + spatial_extent.bottom, + spatial_extent.right, + spatial_extent.top, + ] + ], crs="EPSG:4326", ), temporal=Temporal( diff --git a/api/openapi/openapi_metadata.py b/api/openapi/openapi_metadata.py new file mode 100644 index 00000000..5207d4ef --- /dev/null +++ b/api/openapi/openapi_metadata.py @@ -0,0 +1,15 @@ +openapi_metadata = { + "title": "EDR Observations API Europe EUMETNET", + "description": ( + "OGC EDR API data service for European meteoroligical observations from EUMETNET," + " co-funded by the European Union." + ), + "contact": { + "name": "EUMETNET", + "url": "https://www.eumetnet.eu/about-us/", + }, + "license_info": { + "name": "CC-BY-4.0", + "url": "https://creativecommons.org/licenses/by/4.0/", + }, +}