Skip to content

Commit

Permalink
Improve metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
JimBacon committed Aug 29, 2024
1 parent 6891360 commit 7eb5136
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
5 changes: 5 additions & 0 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
summary="Service for checking species records against the record "
"cleaner rules.",
version="0.0.3",
contact={
"name": "Biological Records Centre at UK Centre for Ecology & Hydrology",
"url": "https://www.ceh.ac.uk/our-science/projects/biological-records-centre",
"email": "[email protected]",
},
openapi_tags=[
{
"name": "Service",
Expand Down
21 changes: 16 additions & 5 deletions app/routes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from fastapi import APIRouter, Depends
from fastapi import APIRouter, Depends, Request
from pydantic import BaseModel

from app.settings import Config
Expand All @@ -17,10 +17,15 @@ class Service(BaseModel):
title: str
version: str
summary: str
contact: str
docs_url: str
swagger_url: str
code_repo: str
rules_repo: str
rules_branch: str
rules_commit: str
maintenance_mode: bool
maintenance_message: str
rules_commit: str


class Maintenance(BaseModel):
Expand Down Expand Up @@ -48,15 +53,21 @@ class SettingResponse(BaseModel):
tags=['Service'],
summary="Show service information.",
response_model=Service)
async def read_service():
async def read_service(request: Request):
base_url = str(request.base_url)[:-1]
return Service(
title=app.app.title,
version=app.app.version,
summary=app.app.summary,
docs_url=app.app.docs_url,
contact=app.app.contact['email'],
docs_url="https://biologicalrecordscentre.github.io/record-cleaner-service/",
swagger_url=base_url + app.app.docs_url,
code_repo="https://github.com/BiologicalRecordsCentre/record-cleaner-service",
rules_repo=settings.env.rules_repo,
rules_branch=settings.env.rules_branch,
rules_commit=settings.db.rules_commit,
maintenance_mode=settings.db.maintenance_mode,
maintenance_message=settings.db.maintenance_message,
rules_commit=settings.db.rules_commit
)


Expand Down

0 comments on commit 7eb5136

Please sign in to comment.