Skip to content

Commit 9f327f3

Browse files
committed
Enhance API metadata and tag consistency across routers for improved documentation and clarity
1 parent d133e30 commit 9f327f3

25 files changed

+247
-26
lines changed

src/mavedb/routers/access_keys.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,24 @@
2121
from mavedb.routers.shared import ACCESS_CONTROL_ERROR_RESPONSES, PUBLIC_ERROR_RESPONSES, ROUTER_BASE_PREFIX
2222
from mavedb.view_models import access_key
2323

24+
TAG_NAME = "Access Keys"
25+
2426
router = APIRouter(
2527
prefix=f"{ROUTER_BASE_PREFIX}",
26-
tags=["Access Keys"],
28+
tags=[TAG_NAME],
2729
responses={**PUBLIC_ERROR_RESPONSES},
2830
route_class=LoggedRoute,
2931
)
3032

33+
metadata = {
34+
"name": TAG_NAME,
35+
"description": "Manage API access keys for programmatic access to the MaveDB API.",
36+
"externalDocs": {
37+
"description": "Access Keys Documentation",
38+
"url": "https://mavedb.org/docs/mavedb/accounts.html#api-access-tokens",
39+
},
40+
}
41+
3142
logger = logging.getLogger(__name__)
3243

3344

src/mavedb/routers/api_information.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,19 @@
66
from mavedb.routers.shared import PUBLIC_ERROR_RESPONSES, ROUTER_BASE_PREFIX
77
from mavedb.view_models import api_version
88

9+
TAG_NAME = "API Information"
10+
911
router = APIRouter(
1012
prefix=f"{ROUTER_BASE_PREFIX}/api",
11-
tags=["API Information"],
13+
tags=[TAG_NAME],
1214
responses={**PUBLIC_ERROR_RESPONSES},
1315
)
1416

17+
metadata = {
18+
"name": TAG_NAME,
19+
"description": "Retrieve information about the MaveDB API.",
20+
}
21+
1522

1623
@router.get("/version", status_code=200, response_model=api_version.ApiVersion, summary="Show API version")
1724
def show_version() -> Any:

src/mavedb/routers/collections.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,22 @@
3333
)
3434
from mavedb.view_models import collection, collection_bundle
3535

36+
TAG_NAME = "Collections"
37+
3638
logger = logging.getLogger(__name__)
3739

3840
router = APIRouter(
3941
prefix=f"{ROUTER_BASE_PREFIX}",
40-
tags=["Collections"],
42+
tags=[TAG_NAME],
4143
responses={**PUBLIC_ERROR_RESPONSES},
4244
route_class=LoggedRoute,
4345
)
4446

47+
metadata = {
48+
"name": TAG_NAME,
49+
"description": "Manage the members and permissions of data set collections.",
50+
}
51+
4552

4653
@router.get(
4754
"/users/me/collections",

src/mavedb/routers/controlled_keywords.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,23 @@
99
from mavedb.routers.shared import PUBLIC_ERROR_RESPONSES, ROUTER_BASE_PREFIX
1010
from mavedb.view_models import keyword
1111

12+
TAG_NAME = "Controlled Keywords"
13+
1214
router = APIRouter(
1315
prefix=f"{ROUTER_BASE_PREFIX}/controlled-keywords",
14-
tags=["Controlled Keywords"],
16+
tags=[TAG_NAME],
1517
responses={**PUBLIC_ERROR_RESPONSES},
1618
)
1719

20+
metadata = {
21+
"name": TAG_NAME,
22+
"description": "Retrieve controlled keywords used for annotating MaveDB records.",
23+
"externalDocs": {
24+
"description": "Controlled Keywords Schema",
25+
"url": "https://github.com/ave-dcd/mave_vocabulary?tab=readme-ov-file",
26+
},
27+
}
28+
1829

1930
@router.get(
2031
"/{key}",

src/mavedb/routers/doi_identifiers.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,19 @@
1010
from mavedb.view_models import doi_identifier
1111
from mavedb.view_models.search import TextSearch
1212

13+
TAG_NAME = "DOI Identifiers"
14+
1315
router = APIRouter(
1416
prefix=f"{ROUTER_BASE_PREFIX}/doi-identifiers",
15-
tags=["DOI Identifiers"],
17+
tags=[TAG_NAME],
1618
responses={**PUBLIC_ERROR_RESPONSES},
1719
)
1820

21+
metadata = {
22+
"name": TAG_NAME,
23+
"description": "Search and retrieve DOI identifiers associated with MaveDB records.",
24+
}
25+
1926

2027
@router.post(
2128
"/search",

src/mavedb/routers/experiment_sets.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,24 @@
1515
from mavedb.routers.shared import ACCESS_CONTROL_ERROR_RESPONSES, PUBLIC_ERROR_RESPONSES, ROUTER_BASE_PREFIX
1616
from mavedb.view_models import experiment_set
1717

18+
TAG_NAME = "Experiment Sets"
19+
1820
router = APIRouter(
1921
prefix=f"{ROUTER_BASE_PREFIX}/experiment-sets",
20-
tags=["Experiment Sets"],
22+
tags=[TAG_NAME],
2123
responses={**PUBLIC_ERROR_RESPONSES},
2224
route_class=LoggedRoute,
2325
)
2426

27+
metadata = {
28+
"name": TAG_NAME,
29+
"description": "Retrieve experiment sets and their associated experiments.",
30+
"externalDocs": {
31+
"description": "Experiment Sets Documentation",
32+
"url": "https://mavedb.org/docs/mavedb/record_types.html#experiment-sets",
33+
},
34+
}
35+
2536
logger = logging.getLogger(__name__)
2637

2738

src/mavedb/routers/experiments.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,26 @@
4141
from mavedb.view_models import experiment, score_set
4242
from mavedb.view_models.search import ExperimentsSearch
4343

44+
TAG_NAME = "Experiments"
45+
4446
logger = logging.getLogger(__name__)
4547

4648
router = APIRouter(
4749
prefix=f"{ROUTER_BASE_PREFIX}",
48-
tags=["Experiments"],
50+
tags=[TAG_NAME],
4951
responses={**PUBLIC_ERROR_RESPONSES},
5052
route_class=LoggedRoute,
5153
)
5254

55+
metadata = {
56+
"name": TAG_NAME,
57+
"description": "Manage and retrieve experiments and their associated data.",
58+
"externalDocs": {
59+
"description": "Experiments Documentation",
60+
"url": "https://mavedb.org/docs/mavedb/record_types.html#experiments",
61+
},
62+
}
63+
5364

5465
# None of any part calls this function. Feel free to modify it if we need it in the future.
5566
@router.get(

src/mavedb/routers/hgvs.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,19 @@
1010
from mavedb.deps import hgvs_data_provider
1111
from mavedb.routers.shared import BASE_400_RESPONSE, PUBLIC_ERROR_RESPONSES, ROUTER_BASE_PREFIX
1212

13+
TAG_NAME = "Transcripts"
14+
1315
router = APIRouter(
1416
prefix=f"{ROUTER_BASE_PREFIX}/hgvs",
15-
tags=["Transcripts"],
17+
tags=[TAG_NAME],
1618
responses={**PUBLIC_ERROR_RESPONSES},
1719
)
1820

21+
metadata = {
22+
"name": TAG_NAME,
23+
"description": "Retrieve transcript information and validate HGVS variants.",
24+
}
25+
1926

2027
@router.get(
2128
"/fetch/{accession}",

src/mavedb/routers/licenses.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,23 @@
88
from mavedb.routers.shared import PUBLIC_ERROR_RESPONSES, ROUTER_BASE_PREFIX
99
from mavedb.view_models import license
1010

11+
TAG_NAME = "Licenses"
12+
1113
router = APIRouter(
1214
prefix=f"{ROUTER_BASE_PREFIX}/licenses",
13-
tags=["Licenses"],
15+
tags=[TAG_NAME],
1416
responses={**PUBLIC_ERROR_RESPONSES},
1517
)
1618

19+
metadata = {
20+
"name": TAG_NAME,
21+
"description": "Retrieve information about licenses supported by MaveDB.",
22+
"externalDocs": {
23+
"description": "Licenses Documentation",
24+
"url": "https://mavedb.org/docs/mavedb/data_licensing.html",
25+
},
26+
}
27+
1728

1829
@router.get("/", status_code=200, response_model=List[license.ShortLicense], summary="List all licenses")
1930
def list_licenses(

src/mavedb/routers/log.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,20 @@
66
from mavedb.lib.logging.context import logging_context, save_to_logging_context
77
from mavedb.routers.shared import PUBLIC_ERROR_RESPONSES, ROUTER_BASE_PREFIX
88

9+
TAG_NAME = "Log"
10+
911
router = APIRouter(
1012
prefix=f"{ROUTER_BASE_PREFIX}/log",
11-
tags=["Log"],
13+
tags=[TAG_NAME],
1214
responses={**PUBLIC_ERROR_RESPONSES},
1315
route_class=LoggedRoute,
1416
)
1517

18+
metadata = {
19+
"name": TAG_NAME,
20+
"description": "Log interactions with the MaveDB API for auditing and debugging purposes.",
21+
}
22+
1623

1724
# NOTE: Despite not containing any calls to a logger, this route will log posted context
1825
# by nature of its inheritance from LoggedRoute.

0 commit comments

Comments
 (0)